1

I've done a 'git --reset hard origin/master' on a local branch so I'm expecting my local branch to match exactly to the remote one. However when I do a:

git log --graph --oneline --decorate --all

I get the following output at the top:

*   dfd9bc6 (refs/stash) On z_tmp2: tmp1
|\  
| * 49f3b6f index on z_tmp2: 84e2002 localconfig
|/  
* 84e2002 localconfig
| * 1110f48 (origin/congo-3.1-stable) Boiler plate code to support

Commits 84e2002, 49f3b6f and dfd9bc6 appear to be local work which I though would've been wiped out by the 'reset --hard', but apparently I'm missing something.

1 Answer 1

1

The reset does not wipe anything out, it only literally resets a branch to a different commit.

As you can see in your log output, you still have a ref (refs/stash, your default stash) pointing to your old commits.

If you do not need those commits any longer and want to make them disappear from the log, use

git stash drop

The actual deletion of the commits from the Git object store will happen with the next run of Git's garbage collector, once the commits are no longer referenced. But unless you have disk space issues, you probably won't have to worry about that.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the clarification. Follow up question: what if I want to keep those commits in my stash but not have them associated with my branch?
they arent associated with the branch. they're associated with their parent commits, which is a relationship you can't break (at least not while maintaining the same commit object)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.