Tuesday, March 1, 2016

Git Merge

git checkout 2.3
git pull origin 2.3
so that u have all 2.3 changes.
then git checkout 2.4
git pull origin 2.4
so that u have all 2.4 changes
i mean locally u have both branches updated
now to merge 2.3 to 2.4
we should be on 2.4 branch
in brackets git show current branch if u using cmd line.
now for merging just do this
git merge 2.3
this would bring all 2.3 changes to 2.4
it would show merge conflict issues if any
 on cmd line
resolve issues
you need to do this manually or using some diff checker

then to commit all these local changes to 2.4
git add .
git commit -am "merge 2.3 to 2.4"
git push origin 2.4
 it would push all merged code to 2.4 branch



Git Process Commands


To change from one branch to other brach

git checkout -b  
ex:  git checkout -b 3.3 



To Undo the last commit or stash the last commit
git stash    -- Do the merge, and than pull the stash:
git stash pop --get the commited files to current branch


Reset the last commit in local
To discard the local changes using
sy: git reset --hard



To change the Last commit message in git



git commit --amend

will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with:

git commit --amend -m "New commit message"



To get the patch to file (all changes to specified file)


Git diff > sample.txt