Git notes
Initialize an empty Git repository in the current directory
git init
Set the global username and mailbox
git config --global user.name "name"
git config --global user.email "[email protected]"
git config user.name
View the Git user namegit config user.email
Viewing Mailbox Configurations
Checking git Configuration
git config --list
Commit changes to staging
git add -A
Commit all changes. (git add-all)git add -u
Commit only changes, not new files. (git add – update)git add .
Do not commit the deleted filegit add <filename>
Submit specified documents
Check the staging area
git status
Modify the latest commit Message
git commit --amend
Modify a commit Message
git commit -i <commit id>
Commit ID Is the commit ID of the parent of the target commit to be modified
Merge consecutive commits
git rebase -i <commit id>
Commit ID is the commit ID of the target commit’s father
Commit changes to the local repository
git commit -m 'msg'
Submit staging area to local warehousegit commit -a -m 'msg'
Commit changes to local repository (do not commit new files)
Viewing the Submission Record
git log
Adding a remote repository
git remote add <name> <url>
View remote warehouse information
git remote show <name>
Delete and rename remote repositories
git remote rm <remote_name>
git remote rename <old_name> <new_name>
Pull remote warehouse data to local
git pull <remote_name> <branch_name>
Commit the local repository to the remote repository
git push <remote_name> <branch_name>
View & Create & switch branches
git branch
View existing branchesgit branch -v
View information about existing branches and the last submitted object for each branchgit branch <branch_name>
Create a new empty branchgit branch <branch_name> <exist_branch_name>
Create a new branchgit checkout -b <branch_name> <exist_branch_name>
Create and switch to a new branchgit checkout <branch_name>
Switch branch
Delete & merge branches
git branch -D <branch_name>
Delete the branchgit merge <branch_name>
The current branch merges into the specified branch
Temporary area restored to HEAD
git reset HEAD
git reset HEAD <file_name>
The workspace restores to the staging area
git checkout -- <file_name>
View all branches
git branch -a
List all (remote trace) branches
git branch -r
Clone Clones specified branches
- Clone with parameters
-b
Specify branch:
Git clone -b branch name https://github.com/ User name/repository name