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的提交记录,精确到行,戏称'缉凶神器'