As we have committed a lot of work inside a branch sometimes we want to go to the branch and go back to several works behind the latest update. I am trying to use the Git Bash but I can only do the cloning of the commit by downloading its zip file. Is there any way instead of downloading the zip file that I can clone a particular commit from a branch which cannot be specifically the master branch?
Asked
Active
Viewed 133 times
1
-
Don’t you already have a local version of the github repo? It contains the entire history. You do not need another clone. Just fetch, to make everything up to date, and then check out the commit. Or am I missing the point? – matt Jun 18 '20 at 03:51
-
1If the server repository has `uploadpack.allowAnySHA1InWant=true`, you can fetch a single commit with `git fetch origin
--depth 1`. But this variable is usually set false by default. And I'm afraid Github does not allow you to set it true. – ElpieKay Jun 18 '20 at 03:54 -
@matt I am using Altium and I am not that familiar with Git Bash. I know how to jump from the commits to commits on Microsoft Visual Studio because it does not require any code on Git Bash and I want to do the same thing on Altium. Can you please show me the code of how to access a particular commit? e.g I clone master and then I need to access a branch and then to a single commit and load only the content of that commit into my project and not the updated one. This would help me a lot understanding the hierarchy of github. – Genoske Jun 18 '20 at 04:05
-
@ElpieKay can you please provide a full access to the commit? eg. 1.git clone
2. – Genoske Jun 18 '20 at 04:063. ... I would really appreciate it. -
You simply log `origin/branch`, locate the commit, and check it out. – matt Jun 18 '20 at 04:10
-
@matt should I do this on GitBash? – Genoske Jun 18 '20 at 04:13
-
I have no idea, sorry. What I described is what you do at the command line. – matt Jun 18 '20 at 04:16
-
1@Genoske If the local repository does not exist yet, use `git init foo; cd foo; git fetch
--depth 1` to fetch the single commit. But I'm afraid Github does not support this feature. -
2Please be aware that git bash is a command line, and git is the version control software. They are not interchangeable. – evolutionxbox Jun 18 '20 at 08:53