简体   繁体   中英

github - commits not found

When using github, this is what I usually do:

  • git pull to make sure if everything is up-to-date
  • git add . to add all my changes
  • git commit -m "some message" to commit my changes
  • git push to push my changes

After every change on my local files, I do the same above operations and go check on the website. The changes are there and everyone can see them. They exist on both local and remote repos. But once in a while, all my commits disappear and they're somehow discarded. I noticed that this happen whenever a colleague working on the same repo makes a change.

If this helps:

  • git log shows that my commits are logged

  • git checkout master says that I am already on master.

  • My Github profile says that I committed X number of commits to the repository, but when I click on them, it says "commits not found".

When on the master branch, are git push and git push origin master different?

I would like to know If I am doing something wrong here, so I can avoid doing it in future commits.

The problem is when he makes a commit, all my changes are gone. They're not even in the history. It's like he is creating a whole new repository every time he makes a change.

That would only happen if he forced a push

git push --force

On GitHub, you could at least protect your master branch .

When on the master branch, are git push and git push origin master different?

You can check the output of git branch -avv : it should show that master has an upstream (remote tracking) branch origin/master . In that case, git push is enough.
See " Why do I need to explicitly push a new branch? "

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