I need help with a really exasperating problem. I'm on the dev team for a github repo, and part of that means I frequently review feature updates by contributors from their own forked branches. To do so, I pull down local copies of their repos and checkout specific branches using this code:
git remote add this_fork this_fork_url
git checkout -b this_fork/this_branch
git branch --set-upstream-to=remotes/this_fork/this_branch this_fork/this_branch
git pull
I have local copies of several contributor repos, as well as the origin, among which I switch frequently. With the contributor repos, I never make code changes, I simply review code and compile & test the application.
Yet, I'm noticing that sometimes, when I checkout one of these contributor branches, git will tell me Your branch is a head of remotes/this_fork/this_branch by ## commits. (use "git push" to publish your local commits)
, or Your branch and 'remotes/this_fork/this_branch' have diverged, and have ## and ## different commits each, respectively. (use "git pull" to merge the remote branch into yours)
. Since I know I made no changes, I try to soldier on by just running a git pull
, but that causes git to force me into a git commit
in the former case, and causes git to perform a merge in the latter. Running git status
shows the same kind of message, but there are no modified files shown.
Once one of my local copies of the forked repos gets in this situation, the only way I've found to fix it is by entirely deleting the local copy of the repo - but this doesn't always help. I've observed on one branch that it remains in the same situation after I delete it entirely, then re-add the remote (in fact, I deleted the entire director & .git dir with all the local repo copies). Running git reset --hard
doesn't help.
This is occurring on both Ubuntu and Windows (the application is cross-platform). Note that this doesn't occur with every remote, every branch, or every time I checkout a branch. I will have no problems with a branch for weeks, then suddenly one day when I check it out, this occurs.
Note that this is not the same as this, in which the author has actually made & pushed changes. In my case, I made no changes.
So I guess my question is two-fold: "Why would git think I've made changes when I have not?" and "How do I fix this?"