1

I worked on a few commits while the origin/master moved forward, and then squashed them together on my local. I still have not committed anything, but even after running git pull --rebase there are still origin/master changes that are not in my local directory.

How could this be? git status shows clean.

Adam Thompson
  • 3,278
  • 3
  • 22
  • 37
  • 1
    How have you ascertained that there are still changes in `origin/master` ? – Tim Biegeleisen Oct 21 '16 at 03:20
  • I am looking at a file that was changed, that I also changed, that has changes I do not. And `git status` shows clean. In fact, the lack of those changes in my local dir is causing a server error. – Adam Thompson Oct 21 '16 at 03:31
  • There is nothing necessarily wrong with this. These other changes may have simply come in with the rebase. If `git status` does not say that your branch is ahead/behind `origin/master`, then it isn't. – Tim Biegeleisen Oct 21 '16 at 03:32
  • Sorry, it's ahead. By clean I meant no merge required or anything. – Adam Thompson Oct 21 '16 at 03:38
  • This looks completely normal, as you _should_ be ahead of `origin/master` after a rebase. Nothing is wrong here. – Tim Biegeleisen Oct 21 '16 at 03:39
  • I am ahead, but I am missing changes? That is normal? – Adam Thompson Oct 21 '16 at 03:42
  • Where does it say you are missing changes? If you _are_ missing changes, then the rebase didn't work. It is _possible_ that you are missing changes from the remote `master` branch. But even in this case, you would not know this from what `git status` shows you, because it uses `origin/master` to report this. – Tim Biegeleisen Oct 21 '16 at 03:44
  • Shouldn't it have merged those changes in with my changes and caused a conflict or just merged them in with my changes when I rebased? Now if I push, the `origin/master` would lose those changes. – Adam Thompson Oct 21 '16 at 03:45
  • `origin/master` is a _local_ branch on your computer. It is _not_ what is in the repository. – Tim Biegeleisen Oct 21 '16 at 03:47
  • Thanks for your help. If I run `git pull --rebase` then it is what is in the remote repository though? That is what I have done. So what I meant is that the remote `origin/master` repository would lose those changes. – Adam Thompson Oct 21 '16 at 03:50
  • `origin/master` is what actually gets updated when you do a `git fetch`. So, if you did a `git fetch` _immediately_ before your rebase, then yes, you rebased on the remote `master` branch. But not necessarily. Even if new stuff has come into the remote, you would find this out when you tried to push. – Tim Biegeleisen Oct 21 '16 at 03:51
  • Isn't `git pull --rebase` exactly just that? A `fetch` and a `rebase`? Why would it tell me when I go to `push`? Because the history is different? But the history is the same. I have the same commits. – Adam Thompson Oct 21 '16 at 03:54
  • Good point, the fetch and rebase might be atomic, but that wouldn't matter if someone else pushed to `master` before you had a chance to fast-forward it. – Tim Biegeleisen Oct 21 '16 at 03:55
  • My advice: Come back here when you have a real question. This isn't a good way to learn Git. – Tim Biegeleisen Oct 21 '16 at 03:56

1 Answers1

2

Checkout to the project that you want to rebase with origin/master.

git checkout

Do a rebase from your current branch to the master branch

git rebase master

If your branch is forked from branch "previous" and you want to fork it from master then

git rebase previous master

Further read this

Community
  • 1
  • 1
Akshay Kumar
  • 160
  • 7