2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
git config user.name [username]
- Set Username
- Add –project to take effect for the current project (default)
- Add –global to take effect for the current user (example: git config --global user.name [user name])
- Add --system to take effect for all users and projects
- Add –get retrieval settings to verify whether the settings are successful
git config user.email [email]
- Set up your mailbox
- Add –project to take effect for the current project (default)
- Add --global to take effect for the current user (example: git config --global user.email [username])
- Add --system to take effect for all users and projects
- Add –get retrieval settings to verify whether the settings are successful
git init
Initialize git repository
git add
- Add [file1] [file2] parameters to add one or more files in the workspace to the cache
- Add the [file] parameter to add the specified file in the workspace to the cache
- Add the . parameter to add all files in the current directory of the workspace to the cache
git status
View the current status of the repository and display the files that have changed
git commit
- Add the -m parameter, msg is the comment information, submit the files in the temporary storage area to the local warehouse
- Add the -a parameter, and you don't need to execute git add. You can directly submit the tracked and modified files to the local repository.
- Add –amend to modify the last submission record
git push
- Add -u origin [branch name], use -u for the first commit and push directly using git push
- Add –set-upstream origin [branch name] to link the remote repository (mandatory method)
git log
- View submission record information
- Add the --oneline parameter, git log information becomes very concise
git ls-files
View local warehouse files
git reset
Add the --hard parameter to reset all regions (excluding remote repositories) directly to the target version (default)
You can use git push -f to force push later.
Add the –soft parameter to reset the files from the local repository to the staging area
Add the --mixed parameter to reset the files from the local repository to the workspace
git restore --staged/–cached
Reset files from the staging area to the working area
git rm
- Delete from git repository (add a deletion record and untrack the file)
- Add the --cached parameter to delete the corresponding file from the cache
git branch
- View git branch
- Add parameters and create a new branch
git checkout/switch
- Add parameters and switch branches
- Add the -b parameter to create a new branch and switch branches
- Add the -d parameter to delete the branch (unmerged branches cannot be deleted)
- Add -D parameter to delete branches (can delete unmerged branches)
git diff
- Directly compare the staging area and the working area
- Add the --cached parameter to compare the staging area and the local warehouse
- Add / parameter to compare local repository and workspace
- Add parameters and compare two branches
git merge/rebase
Merge branches (manually resolve conflicts)
git pull
Equivalent to git fetch + git merge to obtain the remote warehouse address file and merge the local warehouse branch
git remote
- Add the add origin parameter to add the remote repository address
- Add the -v parameter to view the remote address
git clone
- Copy remote warehouse files to local warehouse
- Add -b: select the branch name to copy the remote repository file to the local repository
git stash
- Temporarily save to local, not upload to server
- Add the save [msg] parameter and add some comments
- Add the pop parameter to restore the latest progress to the workspace
- Commonly used: git stash->git pull->git stash pop
git tag
Tagging
git revert
Rollback, reset the corresponding submitted operation
The relevant git commit -m commit naming convention isNamed Types