For any one file, there are only three states in Git: Submitted (committed), modified (modified), and staged (staged). has been submitted to indicate that the file has been securely saved in the local database, has been modified to indicate that a file has been modified, but has not been submitted for saving, and has been staged to place the modified file in the list to be saved on the next commit.
Two, git the work variable setting
1,/etc/gitconfig file: The system for all users are universally applicable configuration. If you use Git config with the--system option, this is the file that you read and write.
2, ~/.gitconfig file: The user directory of the configuration file only applies to the user. If you use Git config with the--global option, this is the file that you read and write.
3. The configuration file in the Git directory of the current project (that is, the. git/config file in the working directory): The configuration here is only valid for the current project. Each level of configuration overwrites the same configuration at the top, so the configuration in the. Git/config overwrites the variable with the same name in/etc/gitconfig.
#用户信息
git config--global user.name "John Doe"
git config--global user.email johndoe@example.com
# Default use of text editor
git config--global core.editor vim
#差异分析工具
git config--global merge.tool vimdiff
Third, the submission, only in changes to be committed under the document will be submitted.
git status
# on branch Master
# Your branch be ahead of ' Origin/master ' by 3 commits.
#
Changes To is committed:
# (use "git reset head <file> ..." to Unstage)
# modified:< C10/>a.txt
#
# Changes not staged for commit:
# (use git add <file> ... "To update what would be Committed)
# (use "Git checkout-<file> ..." to discard changes in working directory)
#
#
modified: a.txt
Skip registers use: Git commit-a-m ' Reason ... '
Four, Git diff
git diff: This command compares the difference between the current file in the working directory and the snapshot of the staging area, which is the change that has not been staged since the modification.
To see the difference between a saved file and a snapshot at the last commit, you can use Git diff--cached
V. Removal of files
git rm: Delete files while deleting traces
git rm--cached filename: Deletes the trace, but retains the local file.
Vi. Viewing the submission record
Git log-p: See details differences
Git log-2: number of record bars
git log--stat: shows a brief increase in the number of rows statistics
Option Description
-(n) displays only the most recent N-Commit
--since,--after shows only submissions after a specified time.
--until,--before only displays submissions before the specified time.
--author displays only the submissions associated with the specified author.
--committer only shows the submission associated with the specified submitter.
git log--pretty=format: "%h-%an,%ar:%s" Set display format
%H a complete hash string of commit objects (commit)%H a short hash string of a commit
object%T a complete hash string of a
tree object (a subtree)
%T A short hash string of a tree object%P a full hash string of a
Parent object (parent)
%p The Parent object's short hash string
%an the author (author) 's name%ae the author
's e-mail address%ad the author's
revised date (which can be customized with the-date= option)
%ar The author's revised date, How long before shows the name of the
%CN Submitter (committer)
%ce The submitter's e-mail address%CD The submission date
%CR The
date of submission, how long before the way to display
%s Submit description
Vii. rolling back
1, git reset head filename: Undo Registers File
2, git checkout-filename: Undo local changes
VIII. Remote Warehouse
See which remote repositories: Git remote-v
Adding remote repositories: Git remote add PB git://github.com/paulboone/ticgit.git
Fetching data from a remote warehouse: git fetch PB
If you set up a branch to track a branch of a remote warehouse, you can use the git pull command to automatically crawl the data down and then automatically merge the remote branch into the current branch in the local warehouse.
Push data to remote repository: Git push origin master
viewing remote Warehouse Information
$ git Remote show Origin
* Remote Origin
url:git@github.com:defunkt/github.git
What branches
will be merged automatically when #运行git pull
What branch remote issues will be merged automatically when remote branch merged with ' git pull ' while on branch issues pull #运行git Branch
With ' git pull ' while on branch master
Master
#有哪些远端分支还没有同步到本地
New remote branches (next fetch would store in Remotes/origin)
caching
#已同步到本地的远端分支在远端服务器上已被删除
stale tracking branches (use ' git Remote prune ')
libwalker
walker2
tracked remote branches
ACL
apiv2
dashboard2 Issues Master
postgres
The default push branch when #运行git push
branch pushed with ' git push '
master:master
Nine, label lightweight (lightweight) and with notes (annotated)
git tag
Git tag-l ' v1.4.2.* ' lists specific labels
Tag with notes git tag-a v0.8.0-m ' my tag v0.8.0 '
See tags: git show v0.8.0
Make up tag: git tag-a v1.2 9fceb02 (checksum number)
Share tags: git push origin--tags/v0.8.0
Ten, the use of skills
1, automatic completion
Download Git's source
Code, entering the Contrib/completion directory, you will see a git-completion.bash file. Copy this file to your own user's home directory (in the following example, you should also change the name plus point: CP gitcompletion.)
Bash ~/.git-completion.bash) and add the following line of content to your. bashrc file:
SOURCE ~/.git-completion.bash
When you enter a git command, you can knock the tab two times, and you will see a list of all the available command suggestions that match:
$ git co<tab><tab>
Commit Config
2. Git Command Alias
$ git config--global alias.co checkout
$ git config--global alias.br branch
$ git config--global alias.ci commi T
$ git config--global alias.st status
Author: 51cto Blog phper-a little bit every day
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/