首页 > 系统 > 其他 >

Git命令

2017-09-12

Git命令。add – add file contents to index 添加修改内容到索引,【1 git add path file java】

add – add file contents to index 添加修改内容到索引
【1. git add path/file.java】

am – apply patches from a mailbox
【1. git am 应用邮件格式补丁】

apply – apply patch to files and/or to index
archimport – import an Arch repository into git
archive – create archive of files from named tree
bisect – find, by binary search, change that introduced a bug
blame – show what revision and author last modified each line 展示文件的历史修改记录
【1. git blame 脚本案例.txt (查看每一行的提交时间 提交时间的不同代表 有队特定行进行修改) 文件逐行追溯 】

4cf14328 (ZukGit 2017-05-29 20:48:09 +0800 9) var1=/ZK500G/
a6bef4ab (ZukGit 2017-08-04 14:21:02 +0800 10) var2= helloworld_code 【时间不同 commit-id不同 有过修改】
4cf14328 (ZukGit 2017-05-29 20:48:09 +0800 11) newPath=”var1""keyValue”“var2”4cf14328(ZukGit2017?05?2920:48:09+080046)var1=/ZK500G/a6bef4ab(ZukGit2017?08?0414:21:02+080047)var2=helloworldcode【时间不同commit?id不同有过修改】4cf14328(ZukGit2017?05?2920:48:09+080048)newPath=”var1""keyValue”“var2”

branch – list, create, or delete branches
【1.git branch 查看分支 】
git branch
TEMP
* master

【2.git branch TEMP( 分支名称 ) 创建分支 】
git branch TEMP

【3.git branch –delete TEMP( 分支名称 ) 删除分支 】
git branch –delete TEMP
Deleted branch TEMP (was a6bef4a).

bundle – move objects and refs by archive
cat-file – provide content or type information for repository obj
check-attr – display gitattributes information
check-ignore – debug gitignore/exclude files
check-mailmap – show canonical names and email addresses of contacts
check-ref-format – ensure that a reference name is well formed

checkout – checkout branch or paths to working tree
【 1.切换分支 (git branch) git checkout master 】
【 2.放弃对某个未加入index(未进行 git add)文件的修改 git checkout file.java】
【 3.新建一个分支 git checkout 分支名( TEMP ) 】

checkout-index – copy files from index to working directory

cherry – find commits not merged upstream
【1. git cherry 查看当前已经commit到本地仓库 但仍未上传到服务器的 提交】
git cherry // 若没有任何新的提交 那么不会显示
1b00e28e6dcc5b3f7cb47660c5d8a900147afb2d //【若有提交到本地仓库 但未上传服务器那么就会显示出 commit-id号码】
【使用 git push origin master 来完成最终的上传到服务器仓库的动作 此时 git cherry就不会显示未提交的commit-id】

cherry-pick – apply changes introduced by some existing commits
citool – graphical alternative to git commit
clean – remove untracked files from working tree
【1. git clean -f 强制清除那些新加入的没有add 没有索引index的文件 不会恢复已修改的文件(需要用checkout 恢复)】

clone – clone repository into new directory 拉取远程URL(git仓库)代码
【1. git clone git@github.com:ZukGit/Source_Code.git 拉取git上的仓库】

commit – record changes to repository (git add把修改内容加入到本地索引index 之后通过commit加入到本地仓库)
【1.把本地添加到索引indes(使用 git add之后的文件)加入到本地仓库 (但该次修改未上传服务器,只在本地)】
git add xxx
git commit -m ”ZukGit 的提交“
[master 1b00e28] test
1 file changed, 1 insertion(+)
create mode 100644 sh/2.txt

commit-tree – create new commit object

config – get and set repository or global options
【1. git config -l 查看当前git配置选项】
credential.helper=osxkeychain
user.name=ZukGit
user.email=382581427@qq.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=git@github.com:ZukGit/Source_Code.git
remote.origin.fetch=+refs/heads/:refs/remotes/origin/
branch.master.remote=origin
branch.master.merge=refs/heads/master

【2. git config –get user.email (user.name) 返回 XXXXX@qq.com Zukgit 】

count-objects – count unpacked objects and display their disk consumpt
cvsexportcommit – export a single commit to a CVS checkout
cvsimport – import a CVS “repository” into a git repository
cvsserver – run a CVS server emulator for git
daemon – run a really simple server for git repositories
describe – show most recent tag that is reachable from a commit

diff – show changes between commits, commit and working tree,
【1. git diff XXX.java //修改本地文件后 查看修改后的内容 于 原来的内容对比】
diff –git a/sh/2.txt b/sh/2.txt
index 52c643f..c6d3d79 100644
— a/sh/2.txt
+++ b/sh/2.txt
@@ -1 +1,2 @@
just a test for cherry
+test2 for git diff
(END)

diff-files – compare files in working tree and index
diff-index – compare content and mode of blobs between index and re
diff-tree – compare content and mode of blobs found via two tree o
difftool – show changes using common diff tools
【1. git difftool XXX.java //打开对比工具 更直观的查看 修改点】

fast-export – data exporter
fast-import – import information into git directly
fetch – download objects and refs from another repository
fetch-pack – receive missing objects from another repository
filter-branch – rewrite branches
fmt-merge-msg – produce merge commit message
for-each-ref – output information on each ref

format-patch – prepare patches for e-mail submission 生成 0001(序号)_CommitMessage(提交信息).patch 文件
【1. git format-patch HEAD^ //生成commit 提交详细记录的patch文件 】
git format-patch HEAD^ //最近的1次commit的patch
git format-patch HEAD^^ //最近的2次commit的patch
git format-patch HEAD^^^ //最近的3次commit的patch
git format-patch HEAD^^^^ //最近的4次commit的patch
git format-patch commit号 //最近的 所有commit的patch

【2. git format-patch .. // 两个commit间的修改(包含两个commit) 】

【3. git format-patch -1 // 单个commit 】

【4. git format-patch // 从某commit以来的修改(不包含该commit) 】

fsck – verify connectivity and validity of objects in databas
gc – cleanup unnecessary files and optimize local repositor
get-tar-commit-id – extract commit ID from an archive created using git ar
grep – print lines matching a pattern
gui – run portable graphical interface to git
hash-object – compute object ID and optionally create a blob from a
help – display help information about git
http-backend – run a server side implementation of Git over HTTP
http-fetch – download from remote git repository via HTTP
http-push – push objects over HTTP/DAV to another repository
imap-send – send a collection of patches to an IMAP folder
index-pack – build pack index file for an existing packed archive
init – create empty git repository or re-initialize an existi
instaweb – instantly browse your working repository in gitweb

log – show commit logs
【1. git log // 查看历史提交记录】
commit a6bef4abc0c9609b6d8ba6cdb904f1eaaac4308e
Author: ZukGit <382581427@qq.com>
Date: Fri Aug 4 14:21:02 2017 +0800

2017年08月04日-14时:21分:02秒_____Zukgit的提交

commit abb5d9be7331d8994ed30b6d0ec87e46e95ebf9b
Author: ZukGit <382581427@qq.com>
Date: Fri Aug 4 14:18:44 2017 +0800

2017年08月04日-14时:18分:44秒_____Zukgit的提交

ls-files &ndash; information about files in index/working directory
ls-remote &ndash; show references in a remote repository
ls-tree &ndash; list contents of a tree object
mailinfo &ndash; extract patch and authorship from a single email messa
mailsplit &ndash; split mbox file into a list of files
merge &ndash; join two or more development histories together
merge-base &ndash; find as good a common ancestor as possible for a merge
merge-file &ndash; run a three-way file merge
merge-index &ndash; run merge for files needing merging
merge-one-file &ndash; standard helper-program to use with git merge-index
merge-tree &ndash; show three-way merge without touching index
mergetool &ndash; run merge conflict resolution tools to resolve merge c
mktag &ndash; create tag object
mktree &ndash; build tree-object from git ls-tree formatted text
mv &ndash; move or rename file, directory, or symlink
name-rev &ndash; find symbolic names for given revisions
notes &ndash; add or inspect object notes
pack-objects &ndash; create packed archive of objects
pack-redundant &ndash; find redundant pack files
pack-refs &ndash; pack heads and tags for efficient repository access
parse-remote &ndash; routines to help parsing remote repository access para
patch-id &ndash; compute unique ID for a patch
prune &ndash; prune all unreachable objects from the object database
prune-packed &ndash; remove extra objects that are already in pack files
pull &ndash; fetch from and merge with another repository or local
push &ndash; update remote refs along with associated objects
quiltimport &ndash; apply a quilt patchset
read-tree &ndash; read tree information into directory index
rebase &ndash; forward-port local commits to the updated upstream hea
receive-pack &ndash; receive what is pushed into repository
reflog &ndash; manage reflog information
relink &ndash; hardlink common objects in local repositories
remote &ndash; manage set of tracked repositories
repack &ndash; pack unpacked objects in a repository
replace &ndash; create, list, delete refs to replace objects
request-pull &ndash; generate summary of pending changes
rerere &ndash; reuse recorded resolution of conflicted merges

reset &ndash; reset current HEAD to specified state
【1. git reset &ndash;hard 1b00e28 (commit-id) 对于当前以提交commit到本地的修改进行撤销 回到原来的状态】
git reset &ndash;hard 1b00e28
HEAD is now at 1b00e28 test

rev-list &ndash; list commit object in reverse chronological order
rev-parse &ndash; pick out and massage parameters for other git commands
revert &ndash; revert existing commits
rm &ndash; remove files from the working tree and from the index
send-email &ndash; send collection of patches as emails
send-pack &ndash; push objects over git protocol to another repository
shell &ndash; restricted login shell for GIT-only SSH access
shortlog &ndash; summarize git log output
show &ndash; show various types of objects
show-branch &ndash; show branches and their commits
show-index &ndash; show packed archive index
show-ref &ndash; list references in a local repository
stash &ndash; stash away changes to dirty working directory

status &ndash; show working-tree status
【1. git status // 查看当前修改状态】

stripspace &ndash; filter out empty lines
submodule &ndash; initialize, update, or inspect submodules
svn &ndash; bidirectional operation between a Subversion repositor
symbolic-ref &ndash; read and modify symbolic references
tag &ndash; create, list, delete or verify tag object signed with
unpack-file &ndash; create temporary file with blob&rsquo;s contents
unpack-objects &ndash; unpack objects from packed archive
update-index &ndash; register file contents in the working directory to the
update-ref &ndash; update object name stored in a reference safely
update-server-info &ndash; update auxiliary information file to help dumb servers
upload-archive &ndash; send archive back to git-archive
upload-pack &ndash; send objects packed back to git fetch-pack

var &ndash; show git logical variable
【1. git var -l //查看当前的配置变量 同 git config -l 】
credential.helper=osxkeychain
user.name=ZukGit
user.email=382581427@qq.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=git@github.com:ZukGit/Source_Code.git
remote.origin.fetch=+refs/heads/:refs/remotes/origin/
branch.master.remote=origin
branch.master.merge=refs/heads/master
GIT_COMMITTER_IDENT=ZukGit <382581427@qq.com> 1504884969 +0800
GIT_AUTHOR_IDENT=ZukGit <382581427@qq.com> 1504884969 +0800
GIT_EDITOR=vi
GIT_PAGER=less

verify-commit &ndash; check GPG signature of commits
verify-pack &ndash; validate packed git archive files
verify-tag &ndash; check GPG signature of tags
whatchanged &ndash; show commit-logs and differences they introduce
write-tree &ndash; create tree from the current index

相关文章
最新文章
热点推荐