Pulling the remote Git Repository and overriding changes in the local copy

Recently after committing a patch, I had this issue when I needed to update my local Git working repository with the main remote of plasma media-center.  The task is not that tough, but still required me to search for it extensively before applying, and then I thought to share it on my blog.


Git Summary Flowchart



If you need to throw away everything in your local copy and update just like a fresh repository, this post is for you !

Note:: Assuming that remote repository is the origin and you are interested in master.

git fetch origin
git reset --hard origin/master
This fetches the all the commits from the remote repository, and position the working copy to the tip of the master branch. However all local commits will be gone. I would suggest having different remotes in that case !
Further, if you want to reapply some changes on top of the remote, this is for you::
git pull --rebase origin master

I would post more Git explorations as and when possible ! 
Cheers!

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment