Git settings
-C keygen -t-RSA SSH "lisemi 163 @ .com" # key generation
git init # initialize the local git repository (to create a new warehouse)
git config --global user.name "xxx" # configure user name
git config --global user.email "[email protected]" # Configure Mail
git config --global color.ui true # git status commands automatic coloring
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global branch.autosetuprebase always # important: pull After synchronization code rebase instead of merge local branch, to reduce unnecessary merger
git config --global pull.rebase true # important: pull After synchronization code rebase instead of merge local branch, to reduce unnecessary merger
git config --global gui.encoding utf-8 #UI utf-8 encoded using
git config --global i18n.commitencoding utf-8 # submitted using utf-8 encoded log
git config --global i18n.logoutputencoding utf-8 #log output using utf-8 format
git config --global color.ui auto # open color output
git config --global alias.lg "log --color --graph --pretty = format: '% Cred% h% Creset% C (bold blue)% an% Creset% C (yellow)% d% Creset% s % Cgreen (% cr) '--abbrev-commit "# git lg increases command, the output of the log landscaping
git config --global core.ignoreCygwinFSTricks true # windows system to solve the problem of slow
Git commonly used commands
git clone git + ssh: //[email protected]/VT.git # clone a remote repository
git status # View the current version status (whether or not modified)
git add xyz # xyz added to the index file
git add. # you add all changed files in the current subdirectory to index
git commit -m 'xxx' # submit
git commit --amend # to enter the last commt Description Edit page, you can submit information on a recent modification
git commit 'xxx' # submission time combined --amend -m (for repeatedly modified)
git commit -am 'xxx' # will add and commit together as one step
git rm xxx # delete files in the index
git rm -r * # recursive delete
git log # commit log display
git log -1 # 1 Line n rows -n Log
git log -5
git log --stat # display the log and the related changes in documents submitted
git log -p -m
git show dfb02e6e4f2f7b573337763e5c0013802e392818 # display the details of a submission
git show dfb02 # can only use the first few commitid
git show HEAD # display HEAD commit log
git show HEAD ^ # display HEAD parent (previous version) commit log ^ ^ ^ 5 to the two versions is the version 5
git tag # show tag already exists
git tag -a v2.0 -m 'xxx' # of increased tag v2.0
git show v2.0 # v2.0 and display the log details
git log v2.0 # v2.0 of the log display
git diff # Display all was not added to the index change
git diff --cached # shows all commit but have not yet been added index changes
git diff HEAD ^ # differences with the previous version
git diff HEAD - the difference compared with the HEAD revision ./lib # lib directory
git diff origin / master there is no local branch of the relatively remote branch master master..master #
git diff origin / master..master --stat # display only the differences between files, does not show the specific content
- - beginning of the line, is only present in the source file line
- + Beginning of the line, is only present in the target file line
- Line that begins with a space, a line of source and destination files are appearing
- Differences organized by differences in summary, the first line of each difference summary is positioning statement, by the end of the beginning @@ @@.
git remote add origin git + ssh: //[email protected]/VT.git # increase remote definition (for push / pull / fetch)
git remote rename origin master # modify remote definition
git branch # Display the local branch
git branch --contains 50089 # display contains a branch of submitting 50089
git branch -a # show all branches
git branch -r # to display all remote branch
git branch --merged # Display all merged into a branch of the current branch
git branch --no-merged # Show all but branch into the current branch
git branch -m master master_copy # local branch renamed
git branch -d hotfixes / BJVEP933 # delete local branch hotfixes / BJVEP933 (this branch changes have been incorporated into other branches)
git branch -D hotfixes / BJVEP933 # forcibly remove the local branch hotfixes / BJVEP933
# Delete remote-thirds
A method :( two statements together)
Branc git H -r -d Origin / Branch-name # delete a remote branch (-r: - remote; -d: - delete), can not add -r
git the Push Origin: Branch-name # delete remote branches, namely pushed to the remote (there is a space before the colon)
Method Two:
git push origin --delete branch-name
git checkout -b master_copy # and change the current branch to create a new branch from the branch master_copy
git checkout -b master master_copy # above full version
git checkout features / performance # existing detection features / performance branch
git checkout --track hotfixes / BJVEP933 # detection remote branch hotfixes / BJVEP933 and create local tracking branch
git checkout v2.0 # v2.0 version detection
git checkout -b devel origin / develop # create a new local branch from a remote branch devel develop and detection
git checkout - README # detection head version of the README file (can be used to modify the error fallback)
git merge origin / master # Merge remote master branch to the current branch
git merge --no-ff feature / new_funciton # merge feature / new_funciton branch to the current branch, the branch history before reservation
git reset --hard HEAD # reset to the current version HEAD (commonly used to merge failure fallback) return to the state before the merger (before submitting)
git the RESET --hard ORIG_HEAD # return to the state before the merger (after submission)
git cherry-pick ff44785404a8e # merge submit a modified ff44785404a8e
git push master # will push the current branch to a remote master branch
git push origin: hotfixes / BJVEP933 # delete remote repository hotfixes / BJVEP933 branch
git push origin test # Create a local branch of the test pushed to the distal
git push --set-upstream origin next # push the local branch of the new local association to a remote repository, branch and remote branch
git push --tags # tag all pushed to the remote repository
git fetch # Get all remote branch (not update the local branch, takes another merge)
git fetch --prune # get all the original branch on the server and remove deleted branches
git pull origin master # obtain remote master branch and merge into the current branch
git pull --rebase # 1 Ba local repo. scratch from the change since the last pull up 2 restored to the state when the last pull, 3 merge remote changes to local, 4 and finally merge just scratch down local changes
git mv README README2 # Rename the file README to README2
git rebase #git rebase used to modify a current branch to branch merge
git ls-files # git index lists the files contained
git show-branch # illustrate the current branch history
git show-branch --all # illustrating the history of all branches
git whatchanged # display documents submitted corresponding modification history
git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # revoked submit dfb02e6e4f2f7b573337763e5c0013802e392818
git ls-tree HEAD # internal commands: display a git objects
git rev-parse v2.0 # internal commands: display a ref for the SHA1 HASH
git reflog # display all submissions, including isolated nodes
git show HEAD@{5}
git show master @ {yesterday} # display state master branch yesterday
git log --pretty = format: '% h% s' --graph # illustrated commit log
git show HEAD~3
git show -s --pretty=raw 2be7fcb476
git stash # modify the current staging, all to the state as HEAD
git stash list # View all Scratch
git stash show -p stash @ {0} # Referring first staging
git stash apply stash @ {0} # application first staging
git grep "delete from" # file search text "delete from"
git grep -e '#define' --and -e SORT_DIRENT
gc git [--aggressive] [--auto] [--quiet] [--prune = <DATE> | --no-Prune] [--force] # clean up unnecessary files and optimize the local repository
- --aggressive # git gc This option will result in more aggressive optimization repository, but spend more time
- --Auto # to check whether the need for any cleaning work; if not, it will exit without performing any work
- --quiet # pruning date older than the loose objects (2 weeks prior to the default, by the configuration variable coverage gc.pruneExpire)
- --prune = <date> # Do not trim any loose objects
- --no-prune # cancel all progress reports
- --force # git gc even though there may be another instance running on this repository, also forced to run
Consistency check git fsck # warehouse, if there are any problems will be reported. This operation is a bit time-consuming
git clone git-address # --bare clone a bare repository (does not include the work area, direct that the repository content)
git clone git-address # --mirror clone a bare repository, cloned upstream of the naked version of the repository is registered, so you can use the command git fetch upstream repositories and continuous synchronization bare repository
git push --mirror git-address # in a mirror pushed upload code to the server; Git clone git push --mirror --bare and compositions can migrate items, such as from github to oschina
remote git the SET -url origin remote_git_address # Change remote origin of the new warehouse address remote_git_address
submodule
git submodule add warehouse address for the current project path # added submodule, the path can not end with a / (cause changes do not take effect), can not be an existing directory existing engineering
Delete submodule modules:
submodule deletion little trouble: first, to delete the configuration information ".gitmodules" file. Then, the file where the sub-modules execute "git rm -cached" command will be removed from the git.
Download the project with a submodule
When using git clone down the project with a submodule, when the initial content submodule does not automatically downloaded, at this time, simply execute the following command:
git submodule update --init --recursive
Or cloning project with references to download directly referenced project (submodule)
git clone --recursive warehouse address
the RESET --soft the commit-the above mentioned id git # git the commit filed a change, but they do not need to change this, and would like to return to the previous comiit ID up , they want to change the code reserved
Newline time window and linux to develop conversion
Under Windows, the carriage return CR (0x0D) and line feed LF (0x0A) jointly mark the end of a line. In Linux and Mac environments, the end of each line is only a line feed LF (0x0A)
// conversion submitted to LF, converted to CRLF when you check git config --global core.autocrlf to true // converted to submit LF, no conversion is detected git config --global core.autocrlf input // submit detected not convert git config --global core.autocrlf false method is greater than the 100M file error handling push :( note that the backup occurs) (1) $ git rm --cached giant_file (prompt greater than 100M wrong file) # Stage our giant file for removal, but leave it on disk (2)$git commit --amend -CHEAD # Amend the previous commit with your change (3)$git push