or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
7.4 0515 Git 小劇場 Part 3
Case 1
git add .
完之後準備要commit,卻發現忘記開分支解法
fish
,git branch fish
,並且趕快git checkout fish
過去。git add .
,git commit
fish
分支上,刪掉master branch
(撕掉貼紙)master branch
(再貼上master貼紙)Case 2 比較機密的檔案不想放在Git裡
解法:
ignore https://github.com/github/gitignore
1.新增
.gitignore
2.編輯
.gitignore
,加入黑名單限制:
之前已經產生的檔案,就算加入了
.gitignore
,還是會被git記錄到。必須先刪除再重新產生一份同名檔案。Case 3 手邊的事情做一半,被老闆叫去修別的bug:
git stash
可能的解法: 切換到master分支,做完再切回來
更好的解法:
git stash
使用git 中斷指令(也是一種commit,只是不會出現在歷史紀錄上)
git stash list
查詢中斷的項目git stash pop
重新回到之前的進度。
重點:
git stash apply
或git stash pop
兩者都可以使用,但pop
指令會把原本的stash砍掉,apply
保留stashCase 4. 線上專案已被其他人執行
git push -f
只能找最接近歷史的一次記錄再
git push -f
蓋回去,然後修改中間改變過的檔案Case 5. 已經push出去的進度該如何reset?
eg. 多人協作的情況下:想取消上次版本的其中一個commit
解法: 使用
reverse commit
reverse commit
reverse commit
會做出新的commit,逆轉上次做的步驟(如果上次commit是新增檔案,這次commit就是刪除檔案)eg. 如果是只有自己一個人的專案,直接reset,commit再
git push -f
就好