Git changes being lost - why?

后端 未结 9 1791
梦如初夏
梦如初夏 2021-02-13 20:42

Our development team is using git and we\'ve lost changes to files at least twice recently. We are using private Github repos.

In the current case, we can go back throug

9条回答
  •  抹茶落季
    2021-02-13 21:32

    Similar thing happened to my team too.

    Lesson learned: when you pull, you should be careful about merge conflicts. If there're conflicts on pull, git doesn't commit merged changes into your local repo and you must do this after you resolve the conflict. Otherwise, while pushing, you will overwrite remote repo with your local copy NOT containing changes of people did in remote before you pulled. This explains some 'strange files' you might see uncommitted but you're sure that's not your changes - this is indication of a merge conflict on 'pull' and - again - you must commit these changes to local after you resolve the conflict and then push to remote.

    If you have no conflicts in merge on pull - no issues with lost changes arise. Because git fetches, merges and commits to your local copy, and 'push' then propagates these merged changes to remote.

提交回复
热议问题