Is it possible to clone a project into a new branch ? I have already cloned the main repo and would like to clone another repo that is a fork of it into a branch. I want to be able to keep comparing the differences using git diff. How can this be done ?
You can clone a specific branch from a Git repository using the git clone –single-branch –branch command. This command retrieves all the files and metadata associated with one branch. To retrieve other branches, you'll need to fetch them later on.
There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.
You can specify a new remote and then call git fetch:
git remote add fork git://example.com/repo.git
git fetch fork
You can then compare branches with
git diff origin/master fork/master
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