Get the App
SLTechnology News&Howtos  ›  Servers  › 

How Linux uses git to check out a single branch

Shulou Source: shulou.com Published: 2022-06-01 12:32:01 10月20日 Update

This article mainly explains "Linux how to use git to detect a separate branch", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux how to use git to detect a separate branch" bar!

Sometimes, you just want to clone a separate branch from the version library (for example, code published by a website), and other related branches do not need to be checked out.

At this point, it is not appropriate to directly use git clone to export the entire version library.

Git clone "url"-branch "branch"-single-branch ["folder"]

But this is slightly different from my actual situation. My code was previously managed by svn and has been published using the svn method on the server. Using this command indicates an error:

Git clone-b qinghaihu-- single-branch.

Because there are already corresponding files in the current directory, there is no problem if you publish to a new directory.

Another answer:

Clone a specific Git branch [duplicate]

That is:

Cd $BRANCH

Git init

Git remote add-t $BRANCH-f origin $REMOTE_REPO

Git checkout-f $BRANCH

Notice that the last checkout command adds a-f argument so that existing files can be forced to be overwritten

Thank you for your reading, the above is the content of "how Linux uses git to detect a separate branch". After the study of this article, I believe you have a deeper understanding of how Linux uses git to detect a separate branch, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Branches learning code content commands situations files versions directories questions different appropriate parameters actual that is ideas articles methods more sometimes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB Docker MySQL Shulou Information