How to fetch two different commits of the same project to different local folders using GIT

StackOverflow https://stackoverflow.com/questions/19125131

  •  30-06-2022
  •  | 
  •  

Domanda

I am new to Git so please bear with me. I am trying to grab two different commits of a same project, specifically a current commit and an old commit with certain hash. I want them to clone it in separate folders (so that they don't overwrite and I can open them as separate projects at same time)? Is it possible?

Thanks in advance

È stato utile?

Soluzione

Normally a clone copies all of a repository's history, so you can just copy the repo and check out the other branch/commit in one of them. For example:

git clone ssh://someserver/repo
cp repo repo2
cd repo
git checkout HASH1
cd ../repo2
git checkout HASH2
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top