简体   繁体   中英

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/

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