The Master branch in Gitlab is set to protected, and for developer members it is necessary to pull a separate branch for development until the stability is later merge into the Master branch. But how do we develop locally based on the developer branch, and how do we pull the developer branch to the local, the push code to the developer branch? Create developer Branch
Note here that if your remote branch is deleted, you will still be able to execute Git branch-a, and this time you can execute git fetch-p. clone remote code to local
After pulling to the local, our branch information is as follows:
58demacbook-pro:responsetimetool wuxian$ git branch-a
* Master
remotes/origin/developer
Remotes/origin /master
This time we were developed in Master Branch master, and all git pull and git push are operated on the master branch. But we don't want to do that. switch to Development on developer Branch
58demacbook-pro:responsetimetool wuxian$ git checkout-b local_developer remotes/origin/developer Branch local_
Developer set up to track remote branch developer from Origin.
Switched to a new branch ' Local_developer '
This time we have switched to development in the Local_developer branch, and the branch was generated by the remote branch developer. git pull
58demacbook-pro:responsetimetool wuxian$ git pull
remote:counting objects:3, done.
Remote:compressing objects:100% (3/3), done.
Remote:total 3 (Delta 2), reused 0 (Delta 0)
unpacking objects:100% (3/3), done.
From
96978FB.. 8a02689 developer -> origin/developer
updating 96978FB. 8a02689
Fast-forward
build.gradle | 1 +
1 file changed, 1 insertion (+)
I manually modified somewhere on the developer branch of the Gitlab page, then pull, showing that it was pulled down with developer, stating that our git pull was successful. git push
But we have a problem executing git push:
58demacbook-pro:responsetimetool wuxian$ git push total
0 (Delta 0), reused 0 (Delta 0) to
git@gitlab.58corp.co M:com.wuba.wuxian.autotest/responsetimetool.git
* [New branch] local_developer-> local_developer
It will generate a new branch by default, the name is the same as my local branch, this is not true, we want to push to the developer branch.
We need to show the execution push to the branch:
58demacbook-pro:responsetimetool wuxian$ git push origin local_developer:developer
counting objects:1, done.
Writing objects:100% (1/1), 175 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (Delta 0)
to
8a02689. 1e27554 local_developer-> Developer
That's OK.