简体   繁体   中英

Discrepancies between remote and local branches

I've encountered this strange issue where I have differences between the remote and local branches even after pushing changes.

Specifically, I will run the following:

  • git add foo.c
  • git commit -m "Some message"
  • git push

Git doesn't produce any errors, but later when I check the remote repository on Github, some changes will not have propagated so that the local and remote copies of foo.c differ slightly. For example, some commented out lines that were deleted in the local copy will remain in the remote.

Running git push , git fetch , and git pull say things are up to date git diff HEAD...origin/<remote-branch> doesn't produce any output.

I've found that I can fix the issue by making a small change (such as adding a space) where there is a discrepancy, adding and committing the file again, and pushing.

Is there anything I can do to avoid this issue?

EDIT: To clarify, I have a remote origin ( https://github.mit.edu/MITMotorsports/MY19 ) that I cloned locally. I then checked-out a new feature branch low-pass , made ~25 commits, pushed to origin (with git push --set-upstream origin low-pass , and then submitted a pull request. When reviewing the 'Files Changed' tab on github, I noticed the remote copy of splitter.c had most, but not all of the changes I had made to it. Trying to add, commit, and push the file again didn't fix the differences.

EDIT: I've specifically noticed this when submitting pull requests and comparing Github's list of files changed. But when I examine the remote version of branch, the discrepancy remains.

Where to push? and what?

First of all you need to create a folder/repository to your github account on the web.

git remote add origin [address of your repository on guithub]

git push origin master (use this every time you want to push after adding)

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