git diff e630759 HEAD --name-only | xargs zip diff.zip
- 1月 03 週四 201911:54
[Git] 打包兩個 commit 之間的所有異動檔案
- 10月 05 週五 201810:42
[Gitbook] 放下載的連結
格式如下
<a href="xxx.zip" download target="_blank">xxx.zip</a>
<a href="xxx.zip" download target="_blank">xxx.zip</a>
- 10月 20 週五 201711:05
[Git] 找回被 reset 掉的 commit
1. 先使用 git reflog 查看剛才你還沒 push 的 commit 在哪
$ git reflog
b846b19 HEAD@{0}: reset: moving to origin/hotfix_#467_fix_email_reveal
ebe56b3 HEAD@{1}: checkout: moving from c50a74fa95aa586738946320a2d6bd013a4fb0e6 to ebe56b3c1cb256e2c07c34db9d5c6a3aff60240c
c50a74f HEAD@{2}: checkout: moving from hotfix_#467_fix_email_reveal to c50a74fa95aa586738946320a2d6bd013a4fb0e6
b846b19 HEAD@{3}: checkout: moving from 9f137318cee420484b7e1c3b70c16ab1debab782 to hotfix_#467_fix_email_reveal
9f13731 HEAD@{4}: checkout: moving from hotfix_#467_fix_email_reveal to 9f13731
b846b19 HEAD@{5}: checkout: moving from 9f137318cee420484b7e1c3b70c16ab1debab782 to hotfix_#467_fix_email_reveal
9f13731 HEAD@{6}: commit: 8787878787
4acb037 HEAD@{7}: checkout: moving from hotfix_#467_fix_email_reveal to 4acb037117557efe4b451fd3af4a7a3fad6a61d4
2. 再下 git checkout 到你消失的 commit (例 87878787)
$ git checkout 9f13731
Previous HEAD position was b846b19... [Feature] - #467 - hide commit message
HEAD is now at 9f13731... 8787878787
$ git reflog
b846b19 HEAD@{0}: reset: moving to origin/hotfix_#467_fix_email_reveal
ebe56b3 HEAD@{1}: checkout: moving from c50a74fa95aa586738946320a2d6bd013a4fb0e6 to ebe56b3c1cb256e2c07c34db9d5c6a3aff60240c
c50a74f HEAD@{2}: checkout: moving from hotfix_#467_fix_email_reveal to c50a74fa95aa586738946320a2d6bd013a4fb0e6
b846b19 HEAD@{3}: checkout: moving from 9f137318cee420484b7e1c3b70c16ab1debab782 to hotfix_#467_fix_email_reveal
9f13731 HEAD@{4}: checkout: moving from hotfix_#467_fix_email_reveal to 9f13731
b846b19 HEAD@{5}: checkout: moving from 9f137318cee420484b7e1c3b70c16ab1debab782 to hotfix_#467_fix_email_reveal
9f13731 HEAD@{6}: commit: 8787878787
4acb037 HEAD@{7}: checkout: moving from hotfix_#467_fix_email_reveal to 4acb037117557efe4b451fd3af4a7a3fad6a61d4
2. 再下 git checkout 到你消失的 commit (例 87878787)
$ git checkout 9f13731
Previous HEAD position was b846b19... [Feature] - #467 - hide commit message
HEAD is now at 9f13731... 8787878787
- 7月 18 週二 201711:48
[Git] 建立 TortoiseGit 使用的 .ppk 檔
1. 使用 ssh-keygen 建立 ssh key
2. 把 id_rsa (私鑰) 另存成 id_rsa.pem
3. 使用 Putty Key Generator 把入 id_rsa.pem
4. 按 Save Private Key 另存成 .ppk 檔
2. 把 id_rsa (私鑰) 另存成 id_rsa.pem
3. 使用 Putty Key Generator 把入 id_rsa.pem
4. 按 Save Private Key 另存成 .ppk 檔
- 1月 20 週五 201712:00
[Git] 取得目前所在的 branch 名稱
指令
$ git branch | grep \* | cut -d ' ' -f2
$ git branch | grep \* | cut -d ' ' -f2
- 11月 04 週五 201610:52
[Git] 取得某個檔案的 commit log

1. git 指令
git log --follow -p {file}
2. git bash 指令 (windows 下,會開內建的 GUI)
gitk {file}
3. SourceTree
先開 File status 畫面,找到你要看的檔案,按右鍵選 [Log Selected...]
再打勾他的選項 [Follow rename files]
- 5月 28 週三 201409:34
[GIT] 指令筆記
1. 將暫存的分支合併回來,不要有線圖
$ git checkout <你要開發的 branch>
$ git merge --squash <你要合併進來的 branch>
$ git branch -D <你要合併進來的 branch>
2. 建立一個 branch 並馬上切換過去
$ git checkout -b <branch name>
3. 刪除遠端的 branch
$ git push origin :<branch name>
4. 還原異動 (revert)
$ git reset --hard HEAD
5. 取消 commit (僅建議對未 push 的 commit 下)
$ git reset --soft HEAD^
6. git 更改遠端資訊
$ git remote -v
$ git remote rm origin
$ git remote add origin git@git-server:project_name
$ git push origin master
7. 修改本地 branch 名稱
$ git branch -m <new_branch_name>
8. 暫存區
目前異動存入暫存區
$ git stash
$ git stash save "WIP: stash_description"
列出所有暫存
$ git stash list
取出異動
$ git stash pop (取出異動但不移除 stash)
$ git stash pop stash@{0}
$ git stash apply (取出異動並移除 stash)
$ git stash apply stash@{0}
9. 只 merge 別的 Branch 的某個 Commit
$ git cherry-pick {commit token}
10. 使用 TAG
建立 TAG
$ git tag -a {tag_name} -m {msg}
push 某個 TAG 到遠端
$ git push orogin {tag_name}
push 所有 TAG 到遠端
$ git push origin --tags
11. 忽略 Linux 底下的檔案權限變動
$ git config core.fileMode false
12. 如果本機和遠端的 branch 清單不一置的時候,下這個指令同步一下
$ git remote update origin --prune
13. 強制更新本機版本與遠端一致
$ git fetch --all
$ git reset --hard origin/master
14. 比對本機與遠端的差異
$ git diff origin/master master
15. 取得目前 commit 的 hash
$ git rev-parse HEAD
$ git rev-parse --short HEAD
16. 刪除所有本機的 branch
$ git branch -D `git branch --merged | grep -v \* | xargs`
17. 取得自動切換換行符號的設定
$ git config core.autocrlf false
18. 取得兩個 commit 之間的 log
取目前版號
$ git rev-parse --short HEAD
$ git checkout <你要開發的 branch>
$ git merge --squash <你要合併進來的 branch>
$ git branch -D <你要合併進來的 branch>
2. 建立一個 branch 並馬上切換過去
$ git checkout -b <branch name>
3. 刪除遠端的 branch
$ git push origin :<branch name>
4. 還原異動 (revert)
$ git reset --hard HEAD
5. 取消 commit (僅建議對未 push 的 commit 下)
$ git reset --soft HEAD^
6. git 更改遠端資訊
$ git remote -v
$ git remote rm origin
$ git remote add origin git@git-server:project_name
$ git push origin master
7. 修改本地 branch 名稱
$ git branch -m <new_branch_name>
8. 暫存區
目前異動存入暫存區
$ git stash
$ git stash save "WIP: stash_description"
列出所有暫存
$ git stash list
取出異動
$ git stash pop (取出異動但不移除 stash)
$ git stash pop stash@{0}
$ git stash apply (取出異動並移除 stash)
$ git stash apply stash@{0}
9. 只 merge 別的 Branch 的某個 Commit
$ git cherry-pick {commit token}
10. 使用 TAG
建立 TAG
$ git tag -a {tag_name} -m {msg}
push 某個 TAG 到遠端
$ git push orogin {tag_name}
push 所有 TAG 到遠端
$ git push origin --tags
11. 忽略 Linux 底下的檔案權限變動
$ git config core.fileMode false
12. 如果本機和遠端的 branch 清單不一置的時候,下這個指令同步一下
$ git remote update origin --prune
13. 強制更新本機版本與遠端一致
$ git fetch --all
$ git reset --hard origin/master
14. 比對本機與遠端的差異
$ git diff origin/master master
15. 取得目前 commit 的 hash
$ git rev-parse HEAD
$ git rev-parse --short HEAD
16. 刪除所有本機的 branch
$ git branch -D `git branch --merged | grep -v \* | xargs`
17. 取得自動切換換行符號的設定
$ git config core.autocrlf false
18. 取得兩個 commit 之間的 log
取目前版號
$ git rev-parse --short HEAD
1
