jstats
jstats

Reputation: 596

Tons of git commits after pulling down a remote branch

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.

Upvotes: 2

Views: 154

Answers (2)

Matt Gibson
Matt Gibson

Reputation: 14959

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.

Upvotes: 2

ralphtheninja
ralphtheninja

Reputation: 133118

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.

Upvotes: 0

Related Questions