Branching in Git with Remote Tracking
Problem: we would like to set up a new branch off of an existing branch in a remote and make sure local/remote tracking is set up properly.
In this example, our remote is Github and we are trying to create a branch named “develop” off of an existing remote branch called “master”.
> git clone email@example.com:zaphpa/zaphpa.git develop > cd develop/ # Branch a new "develop" branch off of master branch > git checkout -b develop master > git status # Push new "develop" branch to origin > git push origin develop > git remote show origin # Make local branch track the upstream branch > git branch --set-upstream develop origin/develop
Note: If you are using GitHub you will need to make a push from the new branch to see it in the GitHub branches view.