My level in regards to git is beginner: I'm basically able to commit, pull, push and switch/create branches.

My current commit is 222222222 and a previous one in the same branch was 111111111.

I want to retrieve the branch as it was on commit 111111111, copy the files it contained and go back to 222222222 so I can continue my work based on that commit. Revert seems to be what I need.

Using revert, I can have the following (revert also commits if I understand properly):

  1. commit 111111111
  2. commit 222222222
  3. revert to 111111111 (it also commits 111111111 again)
  4. revert to 222222222 (it also commits 222222222 again)

But I don't want the reverts to appear in my history.

So how can I actually take a snapshot of my repository at the moment of my commit 111111111?

1 Answer 1


In Git, commits themselves are repository snapshots. You just need to switch between them.

No, git revert is not what you need, because it's specifically made to make the reverts appear in history. The described actions are what git checkout does, instead.

To remain at 22222 but copy some or all files from an older commit:

git checkout 11111 file1.c file2.txt dir1
git checkout 11111 .

(as always, the . means "current directory")

To temporarily switch the entire repository to an old commit, then go back:

git checkout 11111
[copy files]
git checkout master

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.