Git creates / merges branches and submits to remote repositories (combined with vscode)

This article combines code with vscode, because some commands can be visualized through vscode to reduce commands with too much memory.

First, create an initial warehouse on github or code cloud, this step is not much to say, not Baidu. After creation, clone to a local directory

2. Open the cloned project file through vscode.

  ① Writing a new function in the project requires " create a new git branch"

  git checkout -b login // Create a git branch named login

  This step can be achieved by vscode: click to pop up the add branch window

 

 

  git branch // View all git branches

  ②After the creation, the default is to develop and modify the code under this branch (login), without affecting the master branch. . Next, save the code we modified in login to the local git repository

  git add. // Add the modified files and newly added files to the local repository

  git commit -m "add file" // commit the file added to the warehouse

  These two steps can also be achieved through vscode: first click the + sign, then click √

  

 

 

  ③After the development is completed, merge the branch into the master branch and save it to the local warehouse.

 

  git checkout master // switch to the master branch

 

  git merge login // merge the login branch into the main branch

 

  ④ Push the local code to the cloud: git push

 

3. Refresh the cloud github, it is found that the cloud still has only one master branch

  git checkout login // switch to the login branch

  git push -u origin login // Push the login branch to the cloud origin repository

 

 

 

  

 

Guess you like

Origin www.cnblogs.com/jervy/p/12724562.html