The following common Git commands are from ruan Yifeng’s blog post “Git Command List”. Thank you!
warehouse
$Git init [project-name] $Git init [url] $Git init [url] $Git init [url] $Git init [url] $Git init [url] $Git init [url]Copy the code
configuration
$Git config --list $Git config -e [--global] $Git config --list $Git config --list $Git config -e [--global "[name]" $ git config [--global] user.email "[email address]"Copy the code
Add/delete files
$git add [file1] [file2]... $git add. $git add. $git add. $git add. $git add. $git rm [file1] [file2] $git rm [file1] [file2] $git rm [file1] [file2] $git mv [file-original] [file-renamed] $git mv [file-original] [file-renamed]Copy the code
Submit code
$git commit [file1] [file2] $git commit [file1] [file2] $git commit [file1] [file2] - m [message] # change after the workspace since the last commit, directly to the store block $git commit - a # displayed when all the diff information $git commit - v # using a new commit, $git commit --amend -m [message] $git commit --amend -m [message] $git commit --amend [file1] [file2]...Copy the code
branch
$git branch -a # $git branch -a # $git branch -a # $git branch -a # $git branch -a # $git branch -a # $git branch $git checkout -b [branch] $git checkout -b [branch] $git checkout -b [branch] Commit $git branch [branch] [commit] $git branch --track [branch] [remote-branch] $git checkout - $git checkout - $git checkout - $git checkout - $git checkout - $git checkout - $git checkout $git merge [branch] $git merge [branch] $git merge [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch] $git cherry-pick [branch [branch-name] $ git branch -dr [remote/branch]Copy the code
The label
$git tag = "git tag"; $git tag = "git tag" $git push [tag] $git push [tag] $git push [tag] $git push [tag] $git push [tag] $git checkout -b [branch] [tag] $git checkout -b [branch] [tag]Copy the code
Check the information
$git log $git log $git log $git log $git log $git log $git log-s [keyword] # $git log [tag] HEAD --pretty=format:%s # $git log [tag] HEAD --grep feature # $git log --follow [file] $git whatchanged [file] $git log --follow [file] $git whatchanged [file --pretty --oneline # $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff $git diff HEAD # $git diff [first-branch]... $git diff [first-branch]... $git diff --shortstat "@{0 day ago}" $git diff --shortstat "@{0 day ago}" $git diff --shortstat "@{0 day ago}" $git diff --shortstat "@{0 day ago} $git show --name-only [commit] $git show --name-only [commit] $git reflog $git reflog $git reflog $git reflog $git reflogCopy the code
Remote synchronization
$git fetch [remote] $git fetch [remote] $git fetch [remote] $git fetch [remote] $git fetch [remote] $git fetch [remote] $git remote add [shortname] [url] # $git pull [branch] [branch] $git push [branch] [branch] $git push [branch] [branch] $git push [remote] --all $git push [remote] --allCopy the code
undo
$git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit] $git checkout [commit $git reset [file] $git reset [file] $git reset [commit] $git reset [commit] $git reset [commit] $git reset --hard [commit] # reset current HEAD to commit, $git reset --keep [commit] # create a new commit to undo the specified commit # And apply the current branch $git Revert [commit] to remove uncommitted changes for the time being, then move to $git Stash $Git Stash pop laterCopy the code
other
$git Archive = $git archiveCopy the code