current position:Home>Most complete git common commands
Most complete git common commands
2022-06-24 09:57:14【BigChen_ up】
One 、 New code base
# Create a new one in the current directory Git The code base
$ git init
# Create a new directory , Initialize it to Git The code base
$ git init [project-name]
# Download a project and its entire code history
$ git clone [url]
Two 、 To configure
# Show current Git To configure
$ git config --list
# edit Git The configuration file
$ git config -e [--global]
# Set user information when submitting code
$ git config [--global] user.name "[name]"
$ git config [--global] user.email "[email address]"
3、 ... and 、 increase / Delete file
# Add the specified file to the staging area
$ git add [file1] [file2] ...
# Add the specified directory to the staging area , Include subdirectories
$ git add [dir]
# Add all files from the current directory to the staging area
$ git add .
# Add each change before , Will ask for confirmation
# For multiple changes in the same file , It can be submitted in batches
$ git add -p
# Delete workspace file , And put the deletion in the staging area
$ git rm [file1] [file2] ...
# Stop tracking specified files , But the file remains in the workspace
$ git rm --cached [file]
# Rename file , And put it in the temporary storage area
$ git mv [file-original] [file-renamed]
Four 、 Submit code
# Submit staging area to warehouse area
$ git commit -m [message]
# Submit the specified files of staging area to the warehouse area
$ git commit [file1] [file2] ... -m [message]
# Submit workspace since last commit The change after , Go straight to the warehouse area
$ git commit -a
# Show all... On submission diff Information
$ git commit -v
# Use a new commit, Instead of the last submission
# If there are no new changes in the code , To rewrite the last time commit The submission of
$ git commit --amend -m [message]
# Redo the last time commit, And include new changes to specified documents
$ git commit --amend [file1] [file2] ...
5、 ... and 、 Branch
# List all local branches
$ git branch
# List all remote branches
$ git branch -r
# List all local and remote branches
$ git branch -a
# Create a new branch , But still in the current branch
$ git branch [branch-name]
# Create a new branch , And switch to the branch
$ git checkout -b [branch]
# Create a new branch , Point to designated commit
$ git branch [branch] [commit]
# Create a new branch , Establish a trace relationship with the specified remote branch
$ git branch --track [branch] [remote-branch]
# Switch to the specified branch , And update the workspace
$ git checkout [branch-name]
# Switch to the previous branch
$ git checkout -
# Establish a tracking relationship , Between the existing branch and the specified remote branch
$ git branch --set-upstream [branch] [remote-branch]
# Merge the specified branch to the current branch
$ git merge [branch]
# Select a commit, Merge into the current branch
$ git cherry-pick [commit]
# Delete the branch
$ git branch -d [branch-name]
# Delete remote branch
$ git push origin --delete [branch-name]
$ git branch -dr [remote/branch]
6、 ... and 、 label
# List all tag
$ git tag
# Create a new one tag At present commit
$ git tag [tag]
# Create a new one tag In the specified commit
$ git tag [tag] [commit]
# Delete local tag
$ git tag -d [tag]
# Delete remote tag
$ git push origin :refs/tags/[tagName]
# see tag Information
$ git show [tag]
# Submit designation tag
$ git push [remote] [tag]
# Submit all tag
$ git push [remote] --tags
# Create a new branch , Point to something tag
$ git checkout -b [branch] [tag]
7、 ... and 、 Check the information
# Show changed documents
$ git status
# Displays the version history of the current branch
$ git log
# Show commit history , And every time commit Changed documents
$ git log --stat
# Search submission history , According to the key words
$ git log -S [keyword]
# Show a certain commit All the changes since , Every commit Occupy a line
$ git log [tag] HEAD --pretty=format:%s
# Show a certain commit All the changes since , Its " Submit instructions " Must meet search criteria
$ git log [tag] HEAD --grep feature
# Show version history of a file , Include file rename
$ git log --follow [file]
$ git whatchanged [file]
# Displays each time the specified file is related to diff
$ git log -p [file]
# Show past 5 Submission
$ git log -5 --pretty --oneline
# Show all submitted users , Sort by number of submissions
$ git shortlog -sn
# Shows who modified the specified file at what time
$ git blame [file]
# Show differences between staging area and workspace
$ git diff
# Show staging area and previous commit The difference of
$ git diff --cached [file]
# Show workspace and current branch up to date commit Differences between
$ git diff HEAD
# Show the difference between two submissions
$ git diff [first-branch]...[second-branch]
# Show how many lines of code you wrote today
$ git diff --shortstat "@{0 day ago}"
# Show metadata and content changes for a submission
$ git show [commit]
# Show files that have changed in a certain submission
$ git show --name-only [commit]
# Show when a submission , The contents of a document
$ git show [commit]:[filename]
# Shows the most recent commits for the current branch
$ git reflog
8、 ... and 、 Remote synchronization
# Download all changes to remote warehouse
$ git fetch [remote]
# Show all remote warehouses
$ git remote -v
# Show information about a remote warehouse
$ git remote show [remote]
# Add a new remote warehouse , And name
$ git remote add [shortname] [url]
# Change to retrieve remote warehouse , And merge with local branches
$ git pull [remote] [branch]
# Upload local designated branch to remote warehouse
$ git push [remote] [branch]
# Force current branch to remote warehouse , Even if there are conflicts
$ git push [remote] --force
# Push all branches to remote warehouse
$ git push [remote] --all
Nine 、 revoke
# Recover the specified files from the staging area to the workspace
$ git checkout [file]
# To restore something commit To the staging area and workspace
$ git checkout [commit] [file]
# Recover all files from staging area to workspace
$ git checkout .
# Reset the specified file in the staging area , With the last time commit bring into correspondence with , But the workspace doesn't change
$ git reset [file]
# Reset staging area and workspace , With the last time commit bring into correspondence with
$ git reset --hard
# Resets the pointer of the current branch to the specified commit, Also reset staging area , But the workspace doesn't change
$ git reset [commit]
# Resets the... Of the current branch HEAD For a given commit, Reset staging area and workspace at the same time , And specify commit Agreement
$ git reset --hard [commit]
# Reset current HEAD For a given commit, But keep staging area and workspace unchanged
$ git reset --keep [commit]
# Create a new one commit, Used to revoke a designation commit
# All changes in the latter will be offset by the former , And apply to the current branch
$ git revert [commit]
# Temporarily remove uncommitted changes , Move in later
$ git stash
$ git stash pop
Ten 、 other
# Generate a compressed package for publishing
$ git archive
copyright notice
author[BigChen_ up],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/175/202206240807400962.html
The sidebar is recommended
- () is a linear table that restricts the internal structure of data elements to only one character. A. Stack B. queue C. string D. array
- TS cannot find global variable for NPM package
- Java, what should I do if there is an edit configuration in the idea when it runs
- C++ code. Freshmen have just come into contact with this language
- Tnsnames Ora file configuration
- Handling method of Oracle data file header SCN inconsistency
- Oracle database listening file configuration
- Oracle database expdp only exports tables
- Windows method for checking network port occupation and kill process
- Oracle viewing data file header SCN information
guess what you like
Ora-28000 error after upgrading Oracle 12C to 19C
[talk about serviceregistryendpoint of springcloud]
[springcloud service registration and anti registration AOP interception]
[springboot source code analysis - @endpoint annotation validation principle analysis]
[elegant offline and grayscale release of spring cloud]
PostgreSQL
Reactnative 0.69 release
The new design can be called a new generation. The gradient borderless grille has a high appearance value. The application drawing of Changan Ruicheng plus
Linux general command summary
Render external link address URL video page via iframe - Vue
Random recommended
- Detailed explanation of Linux system tuning (VII) -- network status viewing command nethogs
- Vue failed to parse source for import analysis because the content contains invalid JS syntax
- Differences between front-end set and map
- Difference between front-end foreach and map
- Front end array flattening
- How the front end judges the data type
- Front end CSS style expand and collapse
- Front end array de duplication
- Front end throttling and anti shake
- Analysis of 43 cases of MATLAB neural network: Chapter 33 prediction algorithm of fuzzy neural network -- water quality evaluation of Jialing River
- Java & c++ problem solving and expansion -- leetcode30 Concatenate substrings of all words [new knowledge of Mo]
- Eclipse customizes and calls the header file [c/c++]
- Detailed explanation of Vue Foundation
- Unity determines whether all toggles are selected or not
- Program reverse output and print results
- Ubuntu modify time zone
- Linux Installation maven
- Okhttp source code analysis of Android network framework
- Android adds system service interfaces and test cases
- Ubuntu deployment according to Vue version
- Thinkphp5 clear the cache cache, temp cache and log cache under runtime
- Springboot + JWT + redis open source knowledge community system
- Why is JSX syntax so popular?
- The actual test of fluent IOS -- worth collecting
- Front and rear end cross domain issues
- Record the range of data that MySQL update will lock
- Springboot + JWT + redis open source knowledge community system
- 1 minute serverless set up a real website to lead the cat super card: scene experience of "set up nails at a high speed to broadcast the weather regularly"
- 1 minute serverless quickly build a real website to lead the cat super card: scene experience of "rapidly build a zblog blog system"
- Vue eventbus value transfer between brother components
- Array seamless scrolling demo
- Echorts auto play
- Class object oriented programming idea
- elementui utils/clickoutside. JS click element external trigger
- SQL statistics of users logged in for N consecutive days
- Vue3 network request adding loading
- Explain the specific calculation of string hashcode in Java
- Open Oracle server under Linux to allow remote connection
- Properties and simple realization of red black tree
- Vue component introduction and page Jump