Copy an existing Repository: $ gitclonessh: user@domain.comrepo.git
Create
Copy a created warehouse:
$ git clone ssh://user@domain.com/repo.git
Create a new local repository:
$ git init
Local modification
Display the modified files in the working path:
$ git status
Different from the last submitted version File:
$ git diff
Add all current modifications to the next submission:
$ git add
Add modifications to a file to the next submission:
$ git add -p
Submit all local modifications:
$ git commit -a
Submitted previously marked changes:
$ git commit
Additional message submission:
$ git commit -m 'message here'
Submit and set the submission time to a previous date:
git commit --date="`date --date='n day ago'"` -am "Commit Message"
Last modification submitted
Do not modify published submission records!
$ git commit --amend
Move uncommitted changes in the current branch to another branch
git stashgit checkout branch2git stash pop
Search
Search for text from all files in the current directory:
$ git grep "Hello"
Search for text in a specific version:
$ git grep "Hello" v2.5
Submission history
All submission records (hash, author information, submission title, and time) are displayed starting from the latest submission ):
$ git log
Show all submissions (only the submitted hash and message are displayed ):
$ git log --oneline
Display all submissions of a user:
$ git log --author="username"
Display all modifications to a file:
$ git log -p
Who, at what time, modified the content of the file:
$ git blame
Branch and label
List all branches:
$ git branch
Switch branch:
$ git checkout
Create and switch to the new branch:
$ git checkout -b
Create a new branch based on the current branch:
$ git branch
Create a new traceable branch based on the remote branch:
$ git branch --track
Delete local branch:
$ git branch -d
Tag the current version:
$ git tag
Update and release
List the remote end of the current configuration:
$ git remote -v
Display Remote Terminal Information:
$ git remote show
Add a new remote terminal:
$ git remote add
Download the remote version but not merge it into the HEAD:
$ git fetch
Download the remote version and automatically merge it with the HEAD version:
$ git remote pull
Merge the remote version into the local version:
$ git pull origin master
Publish the local version to the remote end:
$ git push remote
Delete remote branch:
$ git push
:
(since Git v1.5.0)
Or
git push
--delete
(since Git v1.7.0)
Release tag:
$ git push --tags
Merge and reset
Merge the branches into the current HEAD:
$ git merge
Reset the current HEAD version to the branch:
Do not reset published submissions!
$ git rebase
Exit reset:
$ git rebase --abort
Continue resetting after resolving the conflict:
$ git rebase --continue
Use the configured merge tool to resolve the conflict:
$ git mergetool
After manually resolving the conflict in the editor, Mark the file as resolved
$ git add
$ git rm
Undo
Discard all modifications in the working directory:
$ git reset --hard HEAD
Remove all files in the cache (I. e. undo the last git add ):
$ git reset HEAD
Discard all local modifications to an object:
$ git checkout HEAD
Reset a commit (by creating a completely different new commit)
$ git revert
Reset the HEAD to the specified version and discard all modifications after the version:
$ git reset --hard
Reset the HEAD to the version submitted last time, and mark the subsequent modifications as those not added to the cache:
$ git reset
Reset the HEAD to the last submitted version, and retain uncommitted local modifications:
$ git reset --keep