How do I update my local repo without losing my already committed changes?

So I forked and cloned and created a new branch, made few changes and made a git commit.

However the original repo (upstream) had some new changes. I want to get them to my local repo and to be exact to the actual branch without losing my already committed changes. I do have one commit right now.

I looked for about an hour on how to do that, but it seems like a dead end without knowing the actual keywords that would get me a result.


Use git pull --rebase it will apply your commit over the new commit.

You can use this:

$ git checkout master # for your current repo
$ git remote add other http://url.git
$ git fetch other
$ git merge other/master # or whatever branch name is the branch you want.

You don't give informations about how you forked the code, but I think you did it through a hosting service (like GitHub).

Anyway the principle is the same:

  • Add the main repository as a remote to be able to push and pull from it
  • Fetch the latest modifications
  • Rebase the modifications onto your work

How to do it in command line:

$ git remote add main http://url.git
$ git fetch main
$ git rebase main/master master

Need Your Help

How to design RESTful search/filtering?

api search rest filter

I'm currently designing and implementing a RESTful API in PHP. However, I have been unsuccessful implementing my initial design.

Overwriting the content from one MOSS content database to another

database sharepoint-2007 import export stsadm

We have a content database on our live moss server. It contains one site collection with several sub-sites. I'm using the stsadm export command to produce a cmp file, then moving this to our test s...