Reputation: 863
I'm quite new to git but I've got my head round the process. Seems to be clone (if it's new), pull, add, commit push... This has worked fine for the most part as the remote repo has a branch called master
as well (thus git push works without any additional commands).
Now I'm in a situation where the repo I've cloned has multiple branches, e.g:
* master
remotes/origin/HEAD
remotes/origin/example
remotes/origin/master
I'd like to add my changes to the example
branch and test. If this is successful I'd then like to merge it with the master
branch.
What commands do I need to run to accomplish these goals?
Upvotes: 0
Views: 87
Reputation: 1217
Adding to Jimmy's answer-
Switch to the branch you want to work on with git checkout <branchname>
, like git checkout example
.
Do the work on that branch with git add
, git commit -m "enter commit message here"
. Check often with git status
.
Reverse merge master to avoid any merge conflicts: git merge master
.
Do any of the tests you'd like to from this branch.
Switch to master: git checkout master
, and merge into master, git merge example
.
Push the changes to the remote branch: git push -u example
.
Upvotes: 3
Reputation: 59
First do git checkout example. Then do all other commands as you will be on example branch.
Upvotes: 1
Reputation: 16825
How about this ?
example
master
so it's up to date (optional)master
example
in mmaster
origin
master
(optional also example
)Upvotes: 1