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 user.name "Your Name"
git config --global user.email you@email.com

#Delete a branch /!\ CAUTION
#Local
git branch -d the_local_branch
#Remote
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

Tags

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.