I have a git clone that is a couple of days old, so I wanted to pull the latest code down from the origin.
I have ZERO local changes.
I do the git pull
and it tells me I need to push my merge commit. Why?
It should just merge the new files into my local branch and not ask me to do anything. I had NO local changes before the pull.
The two things which come to my mind are:
Any "Untracked" changes which come from the environment will cause an issue like this (see: NPM installs or Compilation running locally).
Sometimes a git environment will have a different line-ending encoding from your local system (often if the development moves between Windows and Linux machines it will do it). Depending on your Git client this could be obfuscated by the fact that some of them will hide whitespaces by default.
You can check both of those by running git diff
and seeing if there is any output. If not and you are sure there are no changes you need to get you can do a git reset --hard
and should be able to continue onward with the pull.
If you have a merge commit you did have some changes in your Git repository.
You have few options to verify the changes you made:
git whatchanged
You can always use the command line and use the git whatchanged
command. Full documentation can be found at https://git-scm.com/docs/git-whatchanged .
This command supports many of the git log
flags so you can use them as well
git show
Git show will show you the content of the commit so you will be able to see the changes
If you're really sure that your files are not changed (not even in an unwanted way as supposed by answers) it may be that someone else changed the remote branch commit history with a force push, making your local branch diverging from the remote one.
If you're not afraid to lose something, you can reset your local branch to the remote one with
git fetch
git reset --hard origin/branchname
Otherwise, if you effectively added commits to your local branch, you can ask to git to download the remote branch and try to reapply your commits on top with git pull --rebase
.
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.