configuration
Git’s Settings file is.gitconfig, which can be in the user home directory (global configuration) or in the project directory (project configuration).
**
Git config [--global] Git config [--global "[name]" git config [--global] user.email "[email address]"Copy the code
New local repository (initialization)
Git init [url] # create a new directory and initialize it as a Git repositoryCopy the code
add
**
Git add [file1] [file2]... Git add [dir] add all files from the current directory to the staging area.Copy the code
submit
**
Git commit -m [message]------->[message: commit] git commit [file1] [file2] - m [message] # change after the workspace since the last commit, directly to the store block git commit - a # shows all the diff information git commit - v # using a new commit, Git commit -- amend-m [message] # rewrite the last commit, Git commit --amend [file1] [file2]...Copy the code
branch
Git branch -r git branch -r git branch -r Git branch [branch-name] # create a branch and switch to the branch git checkout -b [branch] # switch to the branch Git checkout [branch name] # merge git branch- # merge git branch Git push origin --delete [branch-name] git branch-dr [remote/branch]Copy the code
Remote synchronization
Git clone [url] git fetch [remote] git remote -v # Git remote show git remote show git remote showCopy the code
Push local branch code to remote branch:
1. Push code to remote associated warehouse for the first time:
git push -u origin master
Copy the code
2. Push to associated warehouse again:
git push
Copy the code
3. Push to specified remote branch:
If your local branch name is the same as the remote name, use the following command:
git push origin branchName
Copy the code
If the local branch is different from the remote branch, specify the names of the local and remote branches:
git push origin localBranchName:remoteBranchName
Copy the code