Tuesday, January 9, 2018

create, push, view bitbucket branches

Before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
Create the branch on your local machine and switch in this branch :
$ git checkout -b [name_of_your_new_branch]
Change working branch :
$ git checkout [name_of_your_new_branch]
Push the branch on github :
$ git push origin [name_of_your_new_branch]
When you want to commit something in your branch, be sure to be in your branch. Add -u parameter to set upstream.
You can see all branches created by using :
$ git branch
boroo@homework MINGW64 /d/Projects/Python.Projects/maths (branch1)
$ git commit -m "change by branch1"
[branch1 f493b16] change by branch1
 1 file changed, 1 insertion(+), 3 deletions(-)

boroo@homework MINGW64 /d/Projects/Python.Projects/maths (branch1)
$ git push
fatal: The current branch branch1 has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin branch1


boroo@homework MINGW64 /d/Projects/Python.Projects/maths (branch1)
$ git push --set-upstream origin branch1
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 281 bytes | 281.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote:
remote: Create pull request for branch1:
remote:   https://bitbucket.org/maths-team/maths-repo/pull-requests/new?source=branch1&t=1
remote:
To https://bitbucket.org/maths-team/maths-repo.git
   221deea..f493b16  branch1 -> branch1
Branch 'branch1' set up to track remote branch 'branch1' from 'origin'.

No comments: