20

My colleague merged some change for a production hotfix into his local master branch and then did a push of master to our GitHub repository. Now I'm try to update my local master branch with his changes. When a do a "git pull origin" from the git console it seems like it going fine by showing all the files. But, near the end it just stops with the message "Aborting".

I have no idea what to do next. Help?

UPDATE: So problem solved. The real root of the problem was that my colleague removed some entries from the .gitignore file in his branch that allowed several new files to come into his checkin. Since my local .gitignore was still ignoring those files, my local repo didn't think I had local working files to add to the index. I ended up deleting all the files and then the pull worked and brought them all in.

I'm definitely going to be more careful editing the .gitignore file and checking it in. I now have some new appreciation for its affect on other developers.

sisdog
  • 2,649
  • 2
  • 29
  • 49
  • Actually, there's one other curiosity that may or may not be related. When my colleague did his push, things 'seemed' like they worked. But, when we went to GitHub, there weren't any new commits. Now his local branch view in GitExtensions looks correct and we were also able to see his changes in GitHub. So when you merge local then push, do you NOT expect to see a new commit on GitHub? And if not, how could I tell that master was changed by looking at GitHub? – sisdog Aug 12 '11 at 00:18
  • 1
    @Tim, it shows you edited my post. Did you change something? I didn't know people could change my post and... why did you change it? – sisdog Aug 12 '11 at 00:21
  • click on the "5 mins ago" in "edited 5 mins ago" and you'll see the diff. He just made a minor punctuation change. – Ben Jackson Aug 12 '11 at 00:24
  • @Ben Jackson: I'm not sure users with <200 rep see the edit button. – Stefan Kendall Aug 12 '11 at 00:25
  • Um, ok. I kinda feel violated. So do we have StackOverflow police now? Why does a stranger have the power to put words in my mouth? When did this start? – sisdog Aug 12 '11 at 00:29
  • 2
    Take this discussion to meta.stackoverflow.com. Editing has been around for a while now. If you'll notice, you see a lot less 'how 2 code this' questions these days. – Stefan Kendall Aug 12 '11 at 00:31
  • 2
    See the [FAQ on editing](http://stackoverflow.com/faq#editing) – Karl Bielefeldt Aug 12 '11 at 02:08
  • Ok, I will conform and do as asked. – sisdog Aug 12 '11 at 03:07
  • git reset --hard && git clean -xdf && git pull solved the issue here – koppor Jul 23 '13 at 16:55

2 Answers2

15

He probably put the commit somewhere in the existing commit tree, rather than on top of it.

Try this:

git fetch origin
git rebase origin/master

And if that doesn't work, just create a local branch of origin, cherry-pick your local commits onto it, reset master before whatever commit he merged, and then merge your local branch onto master.

My guess is that his push involved a --force at some point to avoid a not a fast-forward commit message. You don't want to do that, in the future.

Miguel Mota
  • 20,135
  • 5
  • 45
  • 64
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
  • Thanks @Stefan but I'm still running into issues. At least by running the rebase I received a little more info. At the end it said: Aborting - count not detach HEAD. Does that provide any more of a clue? – sisdog Aug 12 '11 at 01:05
  • Do you have any files locally that would be changed by the rebase? Try checking out a copy of origin to a new branch, and see what that says. `git checkout -b testbranch origin/master` – Stefan Kendall Aug 12 '11 at 01:09
  • Well, I got the same error but this time I scrolled up in the window and learned something more. So, immediately after running the command I get this message: "error: The following untracked working tree files would be overwritten by checkout:". So, that's the real problem. But, what's the solution? I think my collegue altered the .gitignore file which added a bunch of new files into version control. It's showing me all those files. So should I maybe just get the latest .gitignore file first that then commit all the new files? – sisdog Aug 12 '11 at 01:15
  • I'm read http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull but still am not sure of a direction. – sisdog Aug 12 '11 at 01:25
  • So problem solved. The root of the problem was that my colleague removed some entries from the .gitignore file in his branch that allowed several new files to come into his checkin. Since my local .gitignore was still ignoring those files, it didn't think I had local working files to add to the index. I ended up deleting all the files and then the pull worked and brought them all in. – sisdog Aug 12 '11 at 03:00
  • Sounds like you did most of the work. I try not to deal with .gitignore files too much. The downside is that you can miss files you needed to add if you work outside of an IDE, as `relevant-file.groovy` is mixed in with `random-garbage/buildFile.class`. – Stefan Kendall Aug 12 '11 at 03:30
5

The root of the problem was that my colleague removed some entries from the .gitignore file in his branch that allowed several new files to come into his checkin. Since my local .gitignore was still ignoring those files, it didn't think I had local working files to add to the index. I ended up deleting all the files and then the pull worked and brought them all in.

sisdog
  • 2,649
  • 2
  • 29
  • 49