简体   繁体   English

在git pull上丢失对存储库的更改

[英]Changes from repository lost on git pull

I've had a couple issues at work where changes someone else made in the repository are lost when I pull. 我遇到了几个问题,当我提取信息时,存储库中其他人所做的更改会丢失。 I can't figure out why their work, which was committed and pushed, is lost when I pull and then push my commits after merging. 我无法弄清楚为什么在合并后再拉动我的提交后,提交和推送的他们的工作丢失了。 Here is my work flow: 这是我的工作流程:

  1. Add files to staging 将文件添加到暂存
  2. Commit the changed files 提交更改的文件
  3. Pull from remote repository 从远程存储库中提取
  4. Fix any merge conflicts if necessary 如有必要,修复任何合并冲突
  5. Push my commit(s) to the remote repository 将我的提交推送到远程存储库

When I do this, the work done in someone else's last commit will be gone. 当我这样做时,在别人的最后一次提交中完成的工作将消失。 I've been trying to figure out why this is happening and what I could be doing wrong. 我一直试图弄清楚为什么会发生这种情况以及我可能做错了什么。 After all my research, I can't figure out what is wrong with my work flow. 经过所有的研究,我无法弄清工作流程出了什么问题。 Is there a reason, maybe in the merge, for the last commit someone else pushed getting lost? 是否有理由(可能是在合并中)有人推动的最后一次提交迷路了? The merge after pulling is done automatically. 拉动后的合并是自动完成的。

Use fetch instead of pull .. it will solve the problem 使用提取而不是 ..它将解决问题

  1. Add files to staging 将文件添加到暂存
  2. Commit the changed files. 提交更改的文件。
  3. Fetch from remote repository 从远程存储库获取
  4. Merge the local repo changes with your remote repo 将本地存储库更改与远程存储库合并
  5. Fix any merge conflicts if necessary 如有必要,修复任何合并冲突
  6. Push my commit(s) to the remote repository 将我的提交推送到远程存储库

Here is the link which will give deeper look 这是链接,将提供更深入的了解
http://longair.net/blog/2009/04/16/git-fetch-and-merge/ http://longair.net/blog/2009/04/16/git-fetch-and-merge/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM