10 April 2013

git cheat sheet

 git branch -ar;  in order to see all existing branches

apply patch
git add .
git commit --amend 
git push origin HEAD:refs/drafts/master

git checkout -b d_correlation_ver01;create/checkout certain branch
git push origin d_correlation_ver01;push to certain branch

git fetch
git rebase origin/master

git branch -v * version is the branch u r using

update branch name : git branch -m newname

delete a branch 
git branch -d the_local_branch


git pull origin d_correlation_ver01

-- this merges my local copy with the one on the server.


git fetch

-- this takes the my branches server copy one , but I would not see them cos this will be created under the name origin/branch_name


git branch -av (show all branches verbose)


git branch newName originalName
git checkout newName

git branch -vv

git reset --hard originalName

after git 1.8
git branch -u newName

before git1.8
git branch --set-upstream localName  remoteName

push private branch
git push origin privatebranchname


git pull
git commit
git push

if any commit and push occur between this sequence by someone else than you need to rebase as follows;

rebase gives us replaying our changes on top of servers latest copy

git rebase origin branch_name
and if conflict occurs
change the file such as
--git chekcout --theirs filename {to accept file on the server}
--git chekcout --ours filename(to accept file on my machine)
  or go and update the file to do a merge manually which hybrid of 2.
git add filename

git rebase --continue

git push

if rebase origin branch_name does not give any conflict error
git push

git config --global push.default tracking
git commit
pit pull --rebase
git push


git checkout --theirs filename
git checkout --mine filename
git add filename
git rebase --continue
git push

on the workingbranch
git checkout -b temp
git checkout master
git fetch
git reset --hard origin/master
git checkout temp
git rebase origin/master


git diff HEAD~2 HEAD XXX
git diff HEAD^^ HEAD YYY

git diff HEAD~2 HEAD --name-only | grep pom.xml

git rebase -i HEAD^^^
git rebase -i HEAD~3

git push origin HEAD:refs/drafts/master
git commit --amend
git log
 git push origin HEAD:refs/for/master

No comments: