git help
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty Git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG
複製代碼
以上是經過githelp命令得出的全部經常使用的git操做符javascript
git add .
git status
# Changes to be committed:
# new file: add-me
# modified: change-me
# Changed but not updated:
# deleted: delete-me
git reset
git add -u
git status
# Changes to be committed:
# modified: change-me
# deleted: delete-me
# Untracked files:
# add-me
git reset
git add -A
git status
# Changes to be committed:
# new file: add-me
# modified: change-me
# deleted: delete-me
複製代碼
Git-bisect 用於經過二分查找來查尋版本的錯誤,通常用於大工程 詳解css
設定先後兩個版本,一個爲good, 一個爲bad, 使用二分查找中間的版本,進行編譯,看是否出現問題,若是沒有,在該版本與以前設定的bad之間再進行二分;若是有錯誤,則在該版本與以前設定的good之間進行二分,分別設定了兩個版本,一個good, 一個bad, 只要有一個good和一個bad設定完成,就出輸出可能的中間版本,你能夠將該版本checkout, 編譯看是否有bughtml
$ git bisect start
$ git bisect bad # Current version is bad
$ git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
# tested that was good
複製代碼
Git-branch 用於查看該工程存在的分支以及對分支進行操做的命令符java
$ git branch
dev
lyxy-snapshot-1.0.0
master
release
wcxy-snapshot-1.0.0
* zhbx-snapshot-1.0.0
$ git branch -a
dev
lyxy-snapshot-1.0.0
master
release
wcxy-snapshot-1.0.0
* zhbx-snapshot-1.0.0
remotes/origin/HEAD -> origin/master
remotes/origin/cyfw-snapshot-1.0.0
remotes/origin/dev
remotes/origin/lyxy-snapshot-1.0.0
remotes/origin/master
remotes/origin/release
$ git branch -r
origin/HEAD -> origin/master
origin/cyfw-snapshot-1.0.0
origin/dev
origin/lyxy-snapshot-1.0.0
origin/master
origin/release
$ git branch -v
dev 41400c0 [ahead 1] <x>修改BUG.
lyxy-snapshot-1.0.0 c60ee6b Merge branch 'release'
master 8385d99 [behind 18] 修改接口中參數沒有加上company_id的SQL,去掉項目中多餘文件
release 54cac55 [behind 9] +(我的中心學習路徑完成與未完成數量的統計)
wcxy-snapshot-1.0.0 afefba1 [ahead 1] <+>中傳網絡學院的定製化修改
* zhbx-snapshot-1.0.0 a6f5cfd +(用戶模塊:課件完成百分比配置)
複製代碼
git checkout 最爲經常使用的兩種情形是建立分支和切換分支mysql
//基於TAG v8.4.0 開出新分支並切換到該分支
$ git checkout -b tzcpa-snapshot-1.0.0 v8.4.0
Switched to a new branch 'tzcpa-snapshot-1.0.0'
複製代碼
git clone 用於克隆代碼服務器上的代碼到本地git
//克隆時候出現如下代碼表示clone成功
$ git clone ssh://xxxx/2b/Android/mooc-Android-client
Cloning into 'mooc-Android-client'...
remote: Counting objects: 3516, done
remote: Finding sources: 100% (3516/3516)
remote: Total 3516 (delta 1041), reused 3514 (delta 1041)
Receiving objects: 100% (3516/3516), 29.12 MiB | 1.12 MiB/s, done.
Resolving deltas: 100% (1041/1041), done.
Checking connectivity... done.
Checking out files: 100% (3161/3161), done.
複製代碼
git commit 提交工做空間的修改內容到本地倉庫中.需與git add聯合使用web
git diff 比較當前版本與對應的遠程分支的區別sql
-- ps:全部的git diff模式均可以經過輸入大寫字母Q退出bash
//列舉出從tzcpa-snapshot-1.0.0到mater分支全部改動的簡要模式
$ git diff tzcpa-snapshot-1.0.0...master --stat
filters/dev/system-config.properties | 32 +-
.../com/zxy/mobile/base/constant/Constants.java | 3 +
.../mobile/base/constant/SystemConfigConstant.java | 5 +-
.../mobile/base/service/impl/BaseServiceImpl.java | 11 +
.../com/zxy/mobile/foundation/util/StringUtil.java | 6 +-
.../mobile/listener/SaveLoginRecordListener.java | 36 +-
.../service/ask/service/impl/AskServiceImpl.java | 15 +-
.../service/impl/CommunityServiceImpl.java | 8 +-
.../community/service/impl/TrendsServiceImpl.java | 16 +-
.../course/service/impl/CourseServiceImpl.java | 4 +-
//列舉出從tzcpa-snapshot-1.0.0到mater分支全部改動,就會列舉出詳細的區別,+表示新增內容,-表示刪減的內容
$ git diff tzcpa-snapshot-1.0.0...master
diff --git a/filters/dev/system-config.properties b/filters/dev/system-config.properties
index 3333d2a..0d4efeb 100644s/CommonUtils.java | 117 +-
--- a/filters/dev/system-config.properties.java | 2 +-
+++ b/filters/dev/system-config.propertiesss | 6364 ++++++++++++++++++++
@@ -1,37 +1,44 @@share/css/style.css | 140 +-
-jdbc.url=jdbc:mysql://10.162.61.11:3306/zxystudentdb_yy
+#db
+jdbc.url=jdbc:mysql://121.41.24.23:3306/zxystudentdb
jdbc.user=zxystudentadmin
jdbc.password=dreamtech
複製代碼
git fetch 取回branch在服務器上的最新狀態服務器
$ git fetch -p
remote: Counting objects: 265, done
remote: Finding sources: 100% (131/131)
remote: Total 131 (delta 52), reused 129 (delta 52)
Receiving objects: 100% (131/131), 125.86 KiB | 0 bytes/s, done.
Resolving deltas: 100% (52/52), completed with 34 local objects.
From ssh://xxxxx:29418/2b/xxxx-xxx-new
9daaa54..67731b6 ansp-snapshot-1.0.0 -> origin/ansp-snapshot-1.0.0
00cc0ce..73179e5 dev -> origin/dev
7873606..11ebdbc master -> origin/master
7873606..9d7fd98 release -> origin/release
複製代碼
git grep git自帶的檢索器,能夠方便查找
//查找userInfo
$ git grep userInfo
src/main/java/com/zxy/mobile/service/user/service/impl/UserServiceImpl.java: User userInfo = User.dao.findFirs
//顯示行數
$ git grep -n userInfo
src/main/java/com/zxy/mobile/service/user/service/impl/UserServiceImpl.java:456: User userInfo = User.daos
//統計出現的字數
$ git grep -c userInfo
src/main/java/com/zxy/mobile/service/user/service/impl/UserServiceImpl.java:28
//顯示出現該字符的文件名
$ git grep --name-only userInfo
src/main/java/com/zxy/mobile/service/user/service/impl/UserServiceImpl.java
//基於標籤版本8.4.0進行搜索
$ git grep userInfo v8.4.0
v8.4.0:src/main/java/com/zxy/mobile/service/user/service/impl/UserServiceImpl.java: User userInfo = User.dao
//關聯查找,由於沒有符合條件的文件
$ git grep -e log --and -e hello
src/main/webapp/share/index.html: console.log('hello')
//或查找
$ git grep --all-match -e hello -e log
src/main/webapp/share/index.html: src/main/webapp/share/index.html: <div class="weui_dialog">
src/main/webapp/share/index.html:
<div class="weui_dialog_hd">
src/main/webapp/share/index.html:
<strong class="weui_dialog_title">舒適提示</strosrc/main/webapp/share/index.html:
src/main/webapp/share/index.html: <div class="weui_dialog_ft">
src/main/webapp/share/index.html: <a href="javascript:void(0);"
src/main/webapp/share/index.html: console.log("data:" + data);
src/main/webapp/share/index.html: src/main/webapp/share/index.html: console.log('hello')
複製代碼
git blame 能夠打印出git的提交記錄,精確到行,戲稱'緝兇神器'