Tip: Summarize your recent frequently used git commands and their understanding. If there is any interpretation error, welcome to comment
Article Directory
- foreword
- 1. git init
- 2. git add . \ git add file name
- 3. git commit -m "Join the submitted information description"
- 4. The status quo
- Five, git push \ git push -u origin branch name
- Six, git checkout -b branch name
- Seven, git checkout branch name
- Eight, git merge branch name
- Nine, git branch
- 10. git branch -d branch
- Eleven, git rm --cached file name
- Summarize
foreword
更多git命令请查看官方文档
https://gitee.com/all-about-git
提示:以下是我常用的git命令及其理解,请以官方文档为准
1. git init
Initialize a git repository
2. git add . \ git add file name
git add . : add all uncommitted and modified files to the temporary storage area
git add file name: add the file to the temporary storage area
3. git commit -m "Add the submitted information description"
Submit to the local warehouse, and attach the submission description information
4. The status quo
Check uncommitted and modified file status
- Whether to submit to the temporary storage area
1.1 Not submitted to the temporary storage area, the file name is red
1.2 Submitted to the temporary storage area, but not submitted to the local warehouse, the file name is green- Whether to submit to the local warehouse
2.1 Submit to the local warehouse without file display
Five, git push \ git push -u origin branch name
Push the content under this local branch to the corresponding branch of the remote warehouse. For
the first push, add "-u origin branch name" , the remote branch will be automatically created, and the content under the current branch will be pushed to the remote branch.
Afterwards, directly "git push" will push the content under the current branch to the remote branch
Six, git checkout -b branch name
Create a branch and switch to it
Seven, git checkout branch name
switch to this branch
Eight, git merge branch name
The current branch merges other branches (others refer to the branches described later in merge)
Nine, git branch
View all local branches, and you can see the current branch at the same time (there is a * mark in front of the branch, and the color is bright)
10. git branch -d branch
-d Delete the local branch (delete),
before deleting the branch, you must switch to other branches to delete
Eleven, git rm --cached file name
Move the file out of the staging area