|
|
| (未显示同一用户的10个中间版本) |
| 第1行: |
第1行: |
|
| |
|
| == 命令合并 ==
| |
| 命令可以进行合并。
| |
| {{hcdiff|head=|output=<syntaxhighlight lang="bash">
| |
| git add /src/a.js
| |
| git commit -m "edit the file"</syntaxhighlight>|output2=<syntaxhighlight lang="bash">
| |
| git commit -a -m "edit the file"
| |
| </syntaxhighlight>}}
| |
|
| |
| == commit ==
| |
| === rebase ===
| |
| === reset ===
| |
| 查看记录
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git log --oneline</syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
| <div class="pageBoxGreen"><code>^</code> 表示前一次。<code>^^^^</code> 等价于 <code>~4</code>。<br>
| |
| {{hcdiff|head=|output=<syntaxhighlight lang="bash">
| |
| git reset fb69f9d^^^^</syntaxhighlight>|output2=<syntaxhighlight lang="bash">
| |
| git reset fb69f9d~4
| |
| </syntaxhighlight>}}</div>
| |
|
| |
| 取消最后一次 commit。
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git reset fb69f9d^
| |
| # or
| |
| git reset master^
| |
| # or
| |
| git reset HEAD^</syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
| 回退到指定 commit
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git reset fb69f9d</syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
| ==== --mixed ====
| |
| ==== soft ====
| |
| ==== hard ====
| |
|
| |
| === --amend ===
| |
| === 追加文件到 commit ===
| |
| ==== reset ====
| |
| 删除最后一次 commit,重新 commit。
| |
| ==== --amend --no-edit ====
| |
| 将文件并入最后一次 commit。使用 <code>--no-edit</code> 标识不进行编辑 commit 信息。
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git add src/a.js && \
| |
| git commit --amend --no-edit</syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
|
| == 其他 == | | == 其他 == |
| 第97行: |
第51行: |
| git checkout ejs_vue | | git checkout ejs_vue |
| </pre> | | </pre> |
| == 定时拉取代码 ==
| |
| === crontab ===
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| crontab -e</syntaxhighlight>|$}}
| |
| {{hc|/tmp/crontab.90pWnh|<syntaxhighlight lang="text">
| |
| */1 * * * * cd /root/vue-webpack/;/usr/local/bin/git pull origin ejs_vue
| |
| </syntaxhighlight>}}
| |
| 如果服务器端需要编译,可能会导致冲突
| |
| <syntaxhighlight lang="javascript">
| |
| 0 */1 * * * cd /root/vue-webpack/;/usr/bin/git fetch --all;/usr/bin/git reset --hard origin/ejs_vue;/usr/bin/git pull origin ejs_vue;/usr/local/bin/npm run dev</syntaxhighlight>
| |
|
| |
| === PHP ===
| |
| <syntaxhighlight lang="php">
| |
| exec("cd /root/vue-webpack/;/usr/local/bin/git pull origin ejs_vue");</syntaxhighlight>
| |
| === 密码 ===
| |
|
| |
| == 新建分支 == | | == 新建分支 == |
| {| class="wikitable" | | {| class="wikitable" |
| 第200行: |
第138行: |
| {{shc|<syntaxhighlight lang="bash"> | | {{shc|<syntaxhighlight lang="bash"> |
| git mv src/a.js src/b.js</syntaxhighlight>|$|/home/kangkk}} | | git mv src/a.js src/b.js</syntaxhighlight>|$|/home/kangkk}} |
|
| |
| == 远程仓库 ==
| |
| === 临时分支 ===
| |
| {| class="wikitable"
| |
| |-
| |
| | git remote -v || 查询当前远程的版本 || <syntaxhighlight lang="javascript">
| |
| origin git@gitee.com:b***c/ask***-pc.git (fetch)
| |
| origin git@gitee.com:b***c/ask***-pc.git (push)</syntaxhighlight>
| |
| |-
| |
| | <!-- git pull origin master --> || 直接拉取并合并最新代码( 不推荐 ) || 示例
| |
| |-
| |
| | git fetch origin master:mastertmp || 获取最新代码到本地临时分支 || 示例
| |
| |-
| |
| | git diff mastertmp || 查看本地 mastertmp 分支与当前分支的版本差异 ||
| |
| |-
| |
| | git merge mastertmp || 合并最新临时分支到本地分支 ||
| |
| |-
| |
| | git branch -D mastertmp || 删除本地临时分支 ||
| |
| |}
| |
| === 没有临时分支 ===
| |
| {| class="wikitable"
| |
| |-
| |
| | git remote -v || 查询当前远程的版本 || <syntaxhighlight lang="javascript">
| |
| origin git@gitee.com:b***c/ask***-pc.git (fetch)
| |
| origin git@gitee.com:b***c/ask***-pc.git (push)</syntaxhighlight>
| |
| |-
| |
| | git fetch origin master || 获取远端的 origin/master 分支 || 示例
| |
| |-
| |
| | git log -p master..origin/master ||查看本地 master 与远端 origin/master 的版本差异 || 示例
| |
| |-
| |
| | git merge origin/master || 合并远端分支 origin/master 到当前分支 ||
| |
| |}
| |
|
| |
|
| == 重置本地分支 == | | == 重置本地分支 == |
| 第265行: |
第171行: |
| 无文件要提交,干净的工作区 | | 无文件要提交,干净的工作区 |
| </syntaxhighlight>|$|/home/kangkk}} | | </syntaxhighlight>|$|/home/kangkk}} |
|
| |
| == 提交 ==
| |
| === add ===
| |
| {| class="wikitable"
| |
| |-
| |
| ! 参数!! 描述 !! 示例
| |
| |-
| |
| | . || 当前目录全部,递归子目录 || git add .
| |
| |-
| |
| | --all || 当前项目全部,递归子目录 || git add --all
| |
| |-
| |
| | 文件相对地址 || 部分 || git add src/a.js
| |
| |}
| |
|
| |
| === commit ===
| |
|
| |
|
| == git pull == | | == git pull == |
| 第295行: |
第186行: |
|
| |
|
| <code>git pull</code> 出现冲突后可以暂存本地修改 <code>git stash</code>,然后 <code>git pull</code> 更新代码,<code>git stash list</code> 可查看暂存记录列表,释放本地暂存 <code>git stash apply stash@{0}</code>。 | | <code>git pull</code> 出现冲突后可以暂存本地修改 <code>git stash</code>,然后 <code>git pull</code> 更新代码,<code>git stash list</code> 可查看暂存记录列表,释放本地暂存 <code>git stash apply stash@{0}</code>。 |
|
| |
| == diff ==
| |
| 任意两个版本的差异
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git diff master..test</syntaxhighlight>|$}}
| |
| master , test 的共有父分支和 test 分支之间的差异
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git diff master...test</syntaxhighlight>|$}}
| |
| 当前工作目录和上次提交与本地索引间的差异
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git diff</syntaxhighlight>|$}}
| |
| 查看在下次提交时要提交的内容,显示当前的索引和上次提交间的差异
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git diff --cached</syntaxhighlight>|$}}
| |
| 显示工作目录与上次提交时之间的所有差别
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| git diff HEAD</syntaxhighlight>|$}}
| |
| == commit ==
| |
| {{Shc_out|<syntaxhighlight lang="bash">
| |
| git log --stat</syntaxhighlight>|<syntaxhighlight lang="bash">commit 1c791646bf9605c4380f94a84f3a89b8cc2fb60c (HEAD -> dev)
| |
| Merge: 823544a 2b2fa58
| |
| Author: kangjian <kangjian@360.cn>
| |
| Date: Tue Jul 13 11:41:29 2021 +0800
| |
|
| |
| 修改登录页大小
| |
|
| |
| commit 823544a7986d8e2913d443af0a58290b3fbc1f50
| |
| Author: kangjian <kangjian@360.cn>
| |
| Date: Tue Jul 13 11:36:16 2021 +0800
| |
|
| |
| 修改登录页大小
| |
|
| |
| ph-test/.gitignore | 6 +++---
| |
| ph-test/plugin/sign/net.qihoo.design/META-INF/signatures.xml | 10 +++++-----
| |
| ...ndex_page_script.66bceac724c9b0717f19.min.css => index_page_script.3898d67102797bd90e12.min.css} | 2 +-
| |
| .../css/{main_style.66bceac724c9b0717f19.min.css => main_style.3898d67102797bd90e12.min.css} | 0
| |
| ph-test/plugin/sign/net.qihoo.design/index.html | 2 +-
| |
| .../net.qihoo.design/js/{index_page_script.66bceac7.min.js => index_page_script.3898d671.min.js} | 0
| |
| .../js/{index_page_script.66bceac7.min.js.gz => index_page_script.3898d671.min.js.gz} | Bin
| |
| ph-test/plugin/sign/net.qihoo.design/manifest.json | 8 ++++----
| |
| ph-test/view/page/login/Frame.vue | 11 +++++++----
| |
| 9 files changed, 21 insertions(+), 18 deletions(-)
| |
| </syntaxhighlight>|$|/home/kangkk}}
| |
| === 参考 ===
| |
| * https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E5%8E%86%E5%8F%B2
| |
|
| |
| == 回滚 ==
| |
| {{Shc_out|<syntaxhighlight lang="bash">
| |
| git log
| |
| </syntaxhighlight>|<syntaxhighlight lang="bash">commit 71d6d4d66ad34d815372dde78a9afc64397ad3ee (HEAD -> test, origin/test)
| |
| Author: kangkk <365@kangkk.com>
| |
| Date: Tue Mar 9 10:41:05 2021 +0800
| |
|
| |
| 添加package-lock
| |
|
| |
| commit 90cf19e637d4852262e5925094f3c4cae40f10ef
| |
| Merge: 4930a02 edc565d
| |
| Author: kangkk <365@kangkk.com>
| |
| Date: Tue Mar 9 10:31:52 2021 +0800
| |
|
| |
| 修复冲突
| |
|
| |
| commit edc565d95099e428005a415524b6735405efba4e (origin/fix-coverIsNull, fix-coverIsNull)
| |
| Author: kangkk <365@kangkk.com>
| |
| Date: Tue Mar 9 10:28:43 2021 +0800
| |
|
| |
| 修复封面历史问题
| |
|
| |
| commit aba9aaa7c550eb78141c79b618096747be141ca0
| |
| Author: kangkk <365@kangkk.com>
| |
| Date: Tue Mar 9 10:13:55 2021 +0800
| |
|
| |
| 修复封面历史问题
| |
|
| |
| commit 988fb5dd4719e82c951b4cbfbe6b2d784290e1eb
| |
| Author: kangkk <365@kangkk.com>
| |
| Date: Mon Mar 8 18:57:22 2021 +0800
| |
| </syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
| 然后回滚分支
| |
| {{shc|<syntaxhighlight lang="bash">git reset --hard 988fb5dd4719e82c951b4cbfbe6b2d784290e1eb
| |
| </syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
| 查看修改状态
| |
|
| |
| {{shc|<syntaxhighlight lang="bash">git status
| |
| </syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
| 远程仓库删除原有分支
| |
|
| |
| {{shc|<syntaxhighlight lang="bash">git push origin :test
| |
| git push origin test
| |
| </syntaxhighlight>|$|/home/kangkk}}
| |
|
| |
|
| == 分支之间差异 == | | == 分支之间差异 == |
| 第407行: |
第205行: |
| git log --left-right dev...master</syntaxhighlight>|$}} | | git log --left-right dev...master</syntaxhighlight>|$}} |
|
| |
|
| {{leftrightflex| | | {{Double-columns| |
| 注意 commit 后面的箭头,根据我们在 –left-right dev…master 的顺序,左箭头 < 表示是 dev 的,右箭头 > 表示是 master的}} | | 注意 commit 后面的箭头,根据我们在 –left-right dev…master 的顺序,左箭头 < 表示是 dev 的,右箭头 > 表示是 master的}} |
| {{Unknown}} | | {{Unknown}} |