2

First post on SO so please forgive me if I miss something.

I'm new to git and am loving it. Things have been mostly going smoothly with the exception of this..

Developers I'm working with pushed a new branch to our github, call it 'devbranch'

I wanted to pull down 'devbranch' to my Eclipse project (which currently only had master). Following some instructions on a blog and on Pro Git, I used Eclipse's "Pull" (assumably executing 'git pull') and then in terminal executed git checkout -b devbranch origin/devbranch as per http://progit.org/book/ch3-5.html

Which is (I think) exactly what I did on our server which seemed to work. In Eclipse, this set my working copy to 'devbranch' and all the files were there as they should be.

Oddly though, when doing git status or when going to commit the project in Eclipse (which shows which files need to be committed), there are tons of files which seem to be in a modified state? Could anyone help to explain this mishap / what I may have done wrong or how I can fix it? I tried doing another git pull but it just says that my master and devbranch are all up to date..

Thanks in advance everyone. Your tips are much appreciated.

dgw
  • 13,418
  • 11
  • 56
  • 54
jstats
  • 596
  • 4
  • 17
  • With Eclipse 3.7 and egit (from the Marketplace) you can do all this from inside Eclipse. Either do that, or do all from outside Eclipse. Having two differently configured versions of git manipulating your files will most likely be a bad beginners experience. – Thorbjørn Ravn Andersen Mar 20 '12 at 11:18

2 Answers2

2

This could be due to file permissions, or due to line endings (or due to something else entirely, but those two have caused similar issues in the past for me). Git has a setting for each which will tell it to ignore differences between your machine and the repository, but you need to set it up.

Github explains line endings very well and this question will help you with the permissions.

My advice if you're learning git is to avoid any GUI based tool completely and learn the command line stuff first. I found that my IDE just confused the issue.

Community
  • 1
  • 1
Matt Gibson
  • 14,616
  • 7
  • 47
  • 79
  • I hadn't thought of file permissions, I will look into that thanks... After playing around for a bit, i used `git diff devbranch` and it showed that a ton of the files had: old mode 100755, new mode 100644 So I think permissions were spot on! I ran `git config core.filemode false` but if it's anything like .gitignore, the problem is already there so I'm not sure how to undo it. Could I remove the branch from my local and re-do my `git pull` and checkout? Thanks @MattGibson – jstats Mar 20 '12 at 13:00
  • Yes, that would work. Easier to do 'git reset --hard HEAD' though (provided you have no uncommitted changes). – Matt Gibson Mar 20 '12 at 13:11
  • thanks @MattGibson sounds like that would've worked too. I will have to play with the reset function later. I tried just deleting the branch and re-pulling then checking out again (now that I had the modes ignored) and it seemed to work! appreciate your help ++ – jstats Mar 20 '12 at 13:49
0

Eclipse and git makes bells of warning ring in my ears. This might be a shot in the dark, but what I think has gone wrong is that Eclipse has silently overwritten files on disk. What I think happens is basically that you checkout the devbranch (which checks out new versions of the files on disk) but Eclipse doesn't recognize that the files has changed on disk so it doesn't reload them in the IDE. When you happily compile in Eclipse, it will save the cached buffers and overwrite the files on disk.

The solution is to go into settings in Eclipse and turn on auto reload, which I believe is turned off by default.

Check with

git diff

to find out what has changed in those files.

After you have changed settings type in the root directory

git checkout .

to undo the modified files and get back to the state that origin/devbranch was in before Eclipse made these changes. However, this will also undo your own changes, if you have made any that is.

rtn
  • 127,556
  • 20
  • 111
  • 121
  • Thanks @MagnusSkog I used a variant of your `git diff` recommendation and atm I'm thinking it is permissions. Although your shot it the dark is a good one - I believe I did the proper Refreshes and such to keep Eclipse in line but won't be sure. I'm thinking I just need to figure out how to safely remove the branch and re-do it all again while ignoring permissions. I'll heed your advice regarding the IDE stuff and work on sticking to command line ;-) (better to learn the fundamentals anyways!) thx – jstats Mar 20 '12 at 13:04
  • git checkout . (to reset changes), git branch -D devbranch (delete the branch), git checkout --track origin/devbranch (use this to create local tracking branch) – rtn Mar 20 '12 at 13:08
  • thanks @MagnusSkog - I did it something similar - Instead I just did the `git branch -d devbranch` then `git pull` then `git checkout -b devbranch origin/devbranch` and things seemed to work out very well :-) there's a couple files that still want to be committed oddly but much less now and I feel more comfortable with the investigation process. Thanks for helping me learn this ;-) cheers! – jstats Mar 20 '12 at 13:51