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
I really liked answer from torek, but it doesn't provide you commands to "update reflogs", which is exactly what I was looking for. I found this in other answer reverse a git fetch, so I just leave it here to simplify searching for others.
Let's assume that you have your origin remote and your local develop branch is based on master, but your local master is behind origin/master (but you don't see it yet, because you haven't fetched origin yet).
So performing git fetch will add new commits from origin/master and tags to your local repo. In some cases you don't want to see those new commits at all and they will reduce readability of your history.
Having said that, you can "undo" git fetch by doing:
git update-ref refs/remotes/origin/master refs/remotes/origin/master@{1}
All this does is changes the origin/master pointer to the previous state. Maybe you'll have to play with {n} a bit to get the exact state, but in general it may help.