Posts

Showing posts from January, 2011

How to cancel a local GIT commit?

If you want to retain the changed content of the file and  cancel the last commit use:    git reset HEAD^ or git reset HEAD~1   ( both are same) If you dont want to retain the content of the changed file use: git reset --hard HEAD~1

How to update your GIT master branch with the changes made to other branches?

First step you need to do is:   git checkout master   git pull This will make sure you have the latest code from the github repository for the master branch. Now, you want to rebase your branch on top of the master branch.  git checkout branch_name  git rebase master If you want you can do an interactive rebase (git rebase -i master) and squish your commits into a single commit.  You may also have to resolve conflicts with other work that has been done since you branched off of master. Once you've done the rebase, you can then merge your changes into the master branch:  git checkout master  git merge branch_name Then you need to push your changes up to the remote branch so anyone can pull them down: git push origin master That's it you have successfully updated your master with the latest changes in the branch...!!!