0

For instance, I got a link:

https://github.com/git/git/tree/e83c5163316f89bfbde7d9ab23ca2e25604af290

that Github page lists all the files of the repo in the specific commit, but it has no branch or tag, how can I use something like git checkout ... to switch to the status so I can view all the files in my code editor?

CodyChan
  • 1,776
  • 22
  • 35

2 Answers2

1

Exactly what you suggested, with the commit ID

git checkout e83c5163316f89bfbde7d9ab23ca2e25604af290

That creates a "detached head" meaning you have checked out the files but are not on a branch, so can't commit changes to it. That's fine if you just want to examine the files and not make changes, when you're finished just go back to a known branch e.g. git checkout master

To create your own branch from that commit do this instead:

git checkout -b new_branch_name e83c5163316f89bfbde7d9ab23ca2e25604af290

Or equivalently

git branch new_branch_name e83c5163316f89bfbde7d9ab23ca2e25604af290
git checkout new_branch_name
Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
0

You can go git checkout e83c5163316f89bfbde7d9ab23ca2e25604af290 but make sure you have the commit in your local repo.

Matthew Barram
  • 109
  • 1
  • 7
  • 1
    If you would like a more detailed answer you can find one [here](http://stackoverflow.com/questions/4114095/revert-to-a-previous-git-commit) – Matthew Barram Nov 28 '14 at 11:45
  • 1
    You don't need to be "on the same branch" you just need to have that commit in your local repo, which can be done with `git fetch origin` (assuming `origin` is the github remote) – Jonathan Wakely Nov 28 '14 at 11:46
  • Cool - thanks for the correction @JonathanWakely - correction made. – Matthew Barram Nov 28 '14 at 11:48