To be specific, my goal is to have access to this specific commit https://github.com/ankidroid/Anki-Android/commit/73afde67830bb6e49388d0e3a135e945fdbbfc4a
The issue is that the commit is outside a specific branch. So I can't just fetch its branch. git fetch ankidroid 73afde6
(where ankidroid is my local name for this remote) or git pull ankidroid 73afde6
fails. If I do git fetch
the command at least succeed, but the commit 73afde6
is still not known.
CodePudding user response:
Some hosting sites won't allow you to fetch a commit by its hash ID. If you are using such a hosting site, you must find some name that will allow fetching the commit. Fortunately for you, you are using github, which does allow fetching by raw hash ID.1
The trick is that you must use the full hash ID. That is, run:
git fetch ankidroid 73afde67830bb6e49388d0e3a135e945fdbbfc4a
The command:
git fetch ankidroid 73afde6
does not suffice.
(You might want to give the commit a name you can refer to in your local repository, e.g., git fetch ankidroid 73afde67830bb6e49388d0e3a135e945fdbbfc4a:refs/heads/foo
. This creates a new branch name foo
in your local repository, pointing to the fetched commit. This assumes you do not currently have a branch named foo
; if so, substitute in some other name.)
1The new partial clone feature requires this, so it's becoming more common.