1

I use gitk to browse code. I often right-click on a previous commit and reset master branch to here. Then I compile and test the code.

If I close gitk now and restart it, it can no longer see previous commits. Then I have to type in command line git reset --hard origin/master

Is there a way for gitk to always show the full commit history till origin/master?

McBear Holden
  • 5,741
  • 7
  • 33
  • 55

1 Answers1

1

Instead of resetting your branch, just checkout the commit ID you mean to have as your HEAD

git checkout <commit-id>

That way you'll have a detached head and your working copy will be on that commit. When you think you're good, you can just get back to your previous branch:

git checkout <branch>
everton
  • 7,579
  • 2
  • 29
  • 42
  • Not always. If you fiddled with the code on the detached head, git won't accept a simple `git checkout ` and instead complains "error: Your local changes to the following files would be overwritten by checkout" and aborts. – Daniel K. May 12 '23 at 10:41