I need the source code from a specific version of a project (The SonarQube project), but I can't figure out how to pull it from git.
I've added the repo as a remote (git add remote origin
) and pulled the latest version from the master branch, but that is not the version I need.
I know the commit I need is d25bc0e
, but when I try "git fetch origin master d25bc0e
" I get the error "fatal: couldn't find remote ref d25bc0e
".
It could be I'm doing something very wrong, I am not very experienced with Git.
For those wanting to download a specific Commit, steps are below: Go to "Commits" Click the "<>" icon to the right of the desired commit. Select Clone or Download.
While you're working on a repository in Git, you might need to checkout a specific file from another branch. Luckily, Git offers many possible ways to do this task quickly. One of the easiest solutions is to use the git checkout command with the specified file as an argument.
You cannot pull a specific commit.
See more at "Pull a specific commit from a remote git repository"
Once cloned, you can checkout a specific commit (but you would be in a detached branch mode, which is ok if all you need to do is read, and not commit)
git checkout d25bc0e
If you had to do some modification, starting from that commit, you would create a new branch:
git checkout -b newBranch d25bc0e
Note: since Oct. 2014, you might be able to fetch only one commit (Git 2.5, June 2015), only if the remote server allows it.
But here, I would still recommend the classic workflow (clone+checkout).
If you want to get the specific version. You can get it via commit id.
You can get the commit id in logs.
So first try git log to get specific commit id
Then try
git reset --hard commit_id
But this will not allow you to commit the version. This is read only of a specific version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With