0

git beginner here,

I experiment on simple project to get used with git, having a single file, i did couple consecutive amends and commits on it, so to say master gets 3 commits further away from initial commit. Then I try to revert my project to the first commit, i am branching to that first commit using it's hash/ or tag, there i expect to see my file as it's first condition ... but I found it with all amends up to the last commit where master is. Why is that?

If later on i amend and commit on it, getting back to master i found it ok as i left it, also getting one more time to the tag it is ok with my amends at first commit.

The only magic to me is that - why getting few commits back from master does not show my file as it was at the moment of doing those early commits?

Zoe
  • 23,712
  • 16
  • 99
  • 132
K.K.
  • 31
  • 1
  • 6
  • 5
    Please include the exact Git commands you ran, and anything else you did, to match the description you gave us above. I'm not sure you will get an answer just based on this description. – Tim Biegeleisen Sep 14 '18 at 10:42
  • thank you, while logging my routine i found my mistake - not specifying the sha1 to branch from and the result was branching from master, git branch , that seems to be correct command syntax, that thread shows the same - https://stackoverflow.com/questions/2816715/branch-from-a-previous-commit-using-git – K.K. Sep 14 '18 at 11:52
  • Are you sure to have clearly understood what "branch" really means ? When doing `git branch`, you *create* a branch of given name, located by default at your current place, or onto the specified point if any. If you want to go back to a specific state of your history (that is: a given commit) and have your working directory reflecting this state, you need to use `git checkout` instead. – Obsidian Sep 14 '18 at 12:42
  • 1
    @K.K. Please update your question, so others would wasted their time reading it, like what I just did! – Ken Ratanachai S. Sep 14 '18 at 14:04
  • 1
    @Obsidian Thank you, I did mean exactly the same, but your wording described it a lot better than mine. – K.K. Sep 14 '18 at 22:06
  • @KenRatanachaiS. I hope the posted answer closes the topic clearly enough. – K.K. Sep 14 '18 at 22:15

0 Answers0