User Tools

Site Tools


kb:scc:git:git-single-commit

21 Single Commit Clone

There are situations where we don't want to clone a whole repository. E.g. we wanna test a cool open-source tool from GitHub and compiling only the tatest release. Or we have a CI workflow where where project is cloned in some working-directory to test and build it. Or we wanna pass the last commit by USB-stick to a machine without internet connection.

In all these cases it is not necessary to clone/download the whole repository with a lot of commits we don't care about. To clone one commit is enough.

Partially Copying

Git has a command to specify the depth of the clone operation: depth n

$ clone --depth 1 git@gitlab.com:hampel-soft/hse-libraries/hse-logger.git

This command clones only the last (depth 1) commit from the master branch.

If you want to clone the last commit of a specific branch, this command can be extended accordingly:

$ clone --single-branch -b develop --depth 1 git@gitlab.com:hampel-soft/hse-libraries/hse-logger.git

This command clones only the last commit from the develop branch.

kb/scc/git/git-single-commit.txt · Last modified: 2023/07/08 12:19 by joerg.hampel