问题描述:

I am using Source Tree and wanted to update my local branch with new changes from a remote branch before pushing the changes I had worked on. I did a git pull (from the UI, there were 2 commits that I was missing)

However, I discarded that pull request and all the files instead of committing them as I wanted to commit another change first (which I subsequently did).

After that commit, I noticed there were no more pending pull required and I was able to push to the remote branch. However my local branch was missing files that I had discarded. I tried to pull the changes again but it says that my local branch is up to date. I can see on the remote branch that I am missing the files.

I also didn't remove them before my commit. I only discarded them.

If I try to revert that commit, it says it can't as the commit was a merge commit.

How can update my local branch with the missing files?

And also, was there a better way to go about what I did to avoid this?

Thanks!

网友答案:

Based on your response to my comment above.

If you have ran

git pull

It's the same as doing

git fetch + git merge

Meaning, whatever you have pulled from your remote repository must have made it to your local repository.

As for pull request, it's a way to communicate changes you've made on the project. This allows other contributors to review your work, make suggestions or even collaborate on the feature you are developing. After everyone is happy with what you've done people can merge these changes into production; stopping pull request does not discard changes applied by git pull to your local repository.

If you want to revert to previous commit, there are various instructions you could pass to git. For example git reflog + git reset --hard [email protected]{<number>} or git reset --hard HEAD^.

Hope this is of any information.

相关阅读:
Top