Helpful git commands | Drupal 8

Helpful git commands

Submitted by editor on Mon, 11/16/2015 - 16:30

#Download / Get git repository
git clone http://url-of-your-git/project.git

#Show remore url
git remote -v


#Quickly Resolve conflict
grep -lr '<<<<<<<' .
git checkout --ours PATH/FILE
git checkout --theirs PATH/FILE


grep -lr '<<<<<<<' . | xargs git checkout --ours
grep -lr '<<<<<<<' . | xargs git checkout --theirs

#Remove all local changes
git reset --hard
git pull

#Switch / Change / Move HEAD branch
git remote set-head origin new_head_branch

Saving / Caching  Git password
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=28800' #28800=8 hours


#Confugure Name/ EMail
git config --global "Your Name"
git config --global

#Delete a branch /!\ CAUTION
git branch -d the_local_branch
git push origin :the_remote_branch


Show Different:
View finally comited files and the commit ID
git log --name-status HEAD^..HEAD
View A commit's Files
git diff-tree --no-commit-id --name-only -r THE_COIMMIT_ID
View the different
git diff THE_COIMMIT_ID^!

Update local repository info
git fetch

Update Child branch from Original (Mail) branch

git pull origin MMAIN_BRANCH
git fetch origin MMAIN_BRANCH # (pull)

git checkout feature/CHILD_BRANCH
git merge FETCH_HEAD

git add .
git commit -m 'Resolve confilcts'
git push origin HEAD


Add new comment