Pretty often I point bug reporters at random git branches and sometimes they’ll happily compile kernels from sources, but have no idea about git. Unfortunately there doesn’t seem to be a quick how-to tailored to the needs of bug reporters, so let’s fix that.
$ git clone --depth 1 --no-checkout --no-single-branch <git-repo-path>
This clones the git repository, but avoids downloading the entire history. It also avoids to check out the default branch because usually you need a specific branch for testing.
All the following commands only work if the working directory is within the newly cloned git repository.
$ git checkout origin/<branch-name>
will check out the git branch <branch-name> (from the remote git repository) into the local git repository so that you can use it. git will complain about ‘detached HEAD’ but that’s only really important when committing new changes, so just ignore that. If you already have an older clone of the git same remote repository, you first need to update the local git database (in the .git directory in your local repository) with
$ git fetch origin
before checking out the branch again. Even if you need to test the same, but updated branch, you need to do both steps - git doesn’t update anything automatically by default.
If you have patches or other local changes applied, git might complain that there’s a conflict. You can simply remove all local changes with
$ git reset --hard
and then re-do the checkout command. Much more rarely some build artifacts could get in the way (or you just need a quick way to start a clean build),
$ git clean -dfx
will remove any files not in the currently checked-out git commit.