git pull remote branch to local and local switch branch

Pull the remote branch to the local and switch the local branch
Involved operations 1. Pull remote code to local – 2. Merge other branch code locally – 3. Submit local code to remote designated warehouse – 4. Switch branch locally

  1. Pull the remote code to the local
    First make sure you want to switch branches and view all current local and remote branches
git branch -a
git branch

Red is the remote branch, white is the local branch “*” is the local current branch
Let’s switch to the remote branch and create a remote branch locally

git checkout -b local branch name origin/remote branch name
git checkout

The remote code is pulled to the local. The code record is confirmed below.

git log //Print the resignation record of the remote code warehouse
  1. Locally merge other branch codes

Here is to use the branch feature_map_20210608 to merge the dev branch
Check if you are currently on the dev branch

git status //View New Year status
branch

Here you can see that after executing the git status command, the following On branch dev means that it is on the dev branch
After confirmation, merge as follows:

git merge //merge branch name
git merge

The execution of the order is completed, whether it succeeds or not depends on the evidence

First check if it is on the dev branch git status and then git log to see if the merge is successful

git log
  1. Submit the local code to the remote designated warehouse

See here is my latest code, so after confirming it, push it to the remote dev branch

I habitually git pull before pushing

git pull 
git pull

Push to the remote warehouse

git push origin //remote warehouse name
git push

It is recommended to check the project history on git to make sure after pushing it up

  1. Switch branch locally

Check the local branch first

git branch -a
git branch

Then we want to switch to feature_20210601

git checkout branch name

Then git branch -a to check the record and found that it has been switched over

Done! ! ! ! ! ! !

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish