github - 未找到提交

github - commits not found

使用github时,我通常是这样做的:

本地文件每次修改后,我都做同样的操作,然后去网站上查看。变化就在那里,每个人都可以看到。它们存在于本地和远程仓库中。但是偶尔,我所有的提交都会消失,并且它们会以某种方式被丢弃。我注意到,只要在同一个回购上工作的同事进行更改,就会发生这种情况。

如果这有帮助:

在 master 分支上时,git pushgit push origin master 不同吗?

我想知道我是否在这里做错了什么,这样我就可以在以后的提交中避免这样做。

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.

只有他强行推动才会发生这种情况

git push --force

在 GitHub,你至少可以 protect your master branch

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

你可以检查output of git branch -avv:它应该显示 master 有一个上游(远程跟踪)分支 origin/master。那样的话,git push就够了。
参见“Why do I need to explicitly push a new branch?