I've cloned master from my repository and have been making a bunch of edits and local commits. I've now realised this should be a new branch in my remote repository. Normally I'd just push to the remote system, how do I push as a new branch to the remote repos?
In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'... remote: Enumerating objects: 813, done.
git clone --single-branch : By default, git clone will create remote tracking branches for all of the branches currently present in the remote which is being cloned. The only local branch that is created is the default branch.
Simply clone your project's repo twice (or even more often). When your work on a feature branch is done, simply push that branch and check it out on your 2nd copy to run tests there. You can pick up a new story and work on that on your "main" project directory.
Assuming you have't pushed anything yet and your history looks something like
A -- B -- C -- D -- E
^ ^
| |
origin/master master
You can just do the following:
git branch feature
git reset origin/master
to get this:
A -- B -- C -- D -- E
^ ^
| |
| feature
origin/master,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