git-code management

1. Basic understanding of git

Git is an open source distributed version control system; in simple terms, it is a version control tool, code hosting tool

Two, git code management command 

  1. Clone project code: git clone  https://gitee.com/***/*****.git  
  2. Associated remote warehouse: git remote add origin https://gitee.com/***/*****.git 
  3. Create a branch: git branch dev (dev is the branch name)
  4. Delete branch: git branch -d dev (dev is the branch name)
  5. Switch branch: git checkout dev or git switch dev ( error: 'switch' is not a git command. See 'git --help', you need to upgrade the git version)
  6. Create and switch branches at the same time: git checkout -b dev or git switch -c dev

  7. Merge branch: git merge dev (dev is the branch name) --- used to merge the specified branch into the current branch

3. The operation process of git management in actual work

(1) Take over the project for the first time: the company will provide an online warehouse address

  •  If it is an internal server, the project manager will give the user name and password
  • If it is a third-party warehouse, like gitee, coding, you need to register and log in yourself, and the project manager needs to invite you to join this project

(2) Project operation process

  1. Find the project and clone the code git clone  https://gitee.com/***/*****.git  
  2. Switch to the branch you develop: git checkout dev (or use vscode visual operation), develop projects, and write code
  3. After the code is developed (that is, before get off work), submit the code. Considering that multiple people are developing on the same branch, stash (hide) before submitting the code
    1. Hide code written by yourself: git stash
    2. Pull the latest code: git pull
    3. Release the hidden code: git stash pop
    4. Add code to the staging area: git add .
    5. Add from the staging area to the history area: git commit -m "created by dev" (comment information created by dev for writing code)
    6. Upload to the online warehouse: git push 
  4. Merge into the master branch
    1. Switch to the master branch first: git checkout master
    2. Pull the latest code from master: git pull
    3. Merge the dev branch into master: git merge dev
    4. Submit the merged code to git: git push

Fourth, solve the code conflict problem

Guess you like

Origin blog.csdn.net/m0_63304840/article/details/128970374