Git create branch submit remote branch details

Time:2020-5-22

Git create branch submit remote branch details

1. Create local branch

Git branch branch name, for example: git branch 2.0.1.20120806

Note: 2.0.1.20120806 is the branch name, which can be defined at will.

2. Switch local branch

Git checkout branch name, such as switching from master to branch: git checkout 2.0.1.20120806

3. Remote branch is the local branch push to the server。 For example, master is the most typical remote branch (default).

git push origin 2.0.1.20120806

4. The remote branch and the local branch should be distinguished well,Therefore, when pulling a specific branch from the server, you need to specify the name of the remote branch.

git checkout –track origin/2.0.1.20120806

Note that the command requires more than git 1.6.4 because it has the — track parameter! Git will automatically switch to the branch.

5. Submit branch data to remote server

git push origin <local_branch_name>:<remote_branch_name>

For example:

git push origin 2.0.1.20120806:2.0.1.20120806

Generally, if it is not in the branch, it is submitted in this way. If it is currently under 2.0.1.20120806 branch, it can also be submitted directly

git push

6. Delete remote branch

git push origin :develop

1. Create a new branch from the existing branch (such as from the master branch) and a dev branch


Git checkout -b dev

2. After creation, you can see that the branch has been switched to dev


git branch

  * dev
  master

3. Submit the branch to the remote warehouse


git push origin dev

4. Test to obtain dev from remote


git pull origin dev

Or:

If you use the command line and run git fetch, you can get the remote branch information locally and run it again git checkout -b local-branchname origin/remote_branchname  You can map a remote branch to a local branch named local branchname

5. I think it’s important to set git push to pull the default commit branchIn this way, it is convenient to use git push to submit information or git pull to obtain information


git branch --set-upstream-to=origin/dev

Untracking the master


git branch --unset-upstream master

6. Modify the contents of engineering documents at will,Then git commit and git push can be submitted directly to the remote dev branch instead of the master

Thank you for reading, hope to help you, thank you for your support!