How to undo 'git fetch'

sreginogemoh picture sreginogemoh · Feb 24, 2016 · Viewed 36k times · Source

I just added additional remote A to my repo B and then run git fetch A. How can I undo the fetch? If I just remove remote A: git remote remove A1 would it undo fetch?

UPDATE:

$ git remote add A path/to/A
$ git fetch A

The above are commands I run so in result I got all branches fetched to my repo B however I just need one specific branch from repo A and I need it to go in specific folder on repo B but that is another story Merge code between two dfferent git repositories.

Answer

qzb picture qzb · Feb 24, 2016

You can undo all fetches from remote A simply by removing this remote:

git remote remove A

Now just add it again and fetch only single branch:

git remote add A <path/to/repository>
git fetch A <name of branch>