Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

Why does git say I need to push my commit when I have no local changes and then do a git pull?

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.

question from:https://stackoverflow.com/questions/65835654/why-does-git-say-i-need-to-push-my-commit-when-i-have-no-local-changes-and-then

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...