简体   繁体   中英

Git status reports changed files when nothing have been changed on merge

I have a git repository with more than 1350 commits and several branches. Every time I want to pull some changes from Github, I get stuck in a situation that a bunch of files are modified but they aren't. They are always the same and I can discard those "changes" until I run both "git checkout" and "git reset" commands random times in different order.

Anybody have a clue about what is going on? Could the size of the repository? if it is, is there anything I can do in order to reduce the size like deleting old commits or something similar?

Any help would be appreciated.

Regards

Edit:

This issue also happens when I pull from master. This is how I reproduce this issue:

  1. I commit a file in my local repo
  2. The repo is clean without anything pending to be committed.
  3. I pull first to get the latest changes from remote
  4. Git reports that some changes will be overwriting by merge but those files haven't been changed in my commit or in the pending commits in remote.

This issue happen randomly even if my co-workers using the same OS as me (I'm using Ubuntu).

A bunch of files have been modified is surely caused by the out-sync, in other word, commit histories are different between local repository and remote on GitHub. Before pull from remote, you need to verify steps below:

  1. git fetch , it fetch from remote and put it in .git folder, it has no effect on your local repo working directory and stage area
  2. Switch your local branch to A, git checkout A
  3. Find out-sync commits which exist in local branch A but not in remote branch origin/A. git log origin/A..A , if it has output after the command, you need to push the changes to remote firstly, and then do these steps again.
  4. Find out-sync commits which exist in remote branch origin/A but not in local branch A. git log A..origin/A , if it has output after the command, that means you need to pull from remote.

Note: before you pull from remote, please make sure step3 has no output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM