-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgitnote.txt
More file actions
47 lines (35 loc) · 2.32 KB
/
gitnote.txt
File metadata and controls
47 lines (35 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
查看 ls
看內容 cat 檔名
創建目錄 mkdir 名稱
切換到目錄 cd 名稱
顯示當前目錄路徑 pwd
將此目錄變成git可以管理的倉庫 git init
添加到倉庫 git add 檔名
提交到倉庫 git commit -m "更新了什麼"
查看倉庫狀態 git status
修改狀態 git diff 檔名
查看歷史紀錄 git log
找commit id git reflog
回到上一個版本 git reset --hard HEAD^
回到某版本 git reset --hard (git log 或 git reflog 找 commit id)
回復到上次add或commit的狀態 git checkout -- 檔名
工作區文件刪除或rm test.txt
1.復原: git restore test.txt
2.將版本庫也刪除:git rm test.txt
git commit -m"remove test"
復原: git reset --hard HEAD^ 或 git reset --hard (commit id)
要關聯一個遠程庫,使用命令 git remote add origin git@github.com:帳戶名/repository名.git;
關聯一個遠程庫時必須給遠程庫指定一個名字,origin是默認習慣命名;
關聯後,使用命令 git push -u origin master第一次推送master分支的所有內容;
此後,每次本地提交後,只要有必要,就可以使用命令git push origin master推送最新修改;
查看遠程庫 git remote -v
刪除遠程庫 git remote rm 庫名
從github克隆: git clone git@github.com:帳戶名/repo名.git
創建分支並切換過去: git checkout -b 分支名
git switch -c 分支名
查看當前分支: git branch
轉換到master/dev分支 git checkout master/dev
git switch master/dev
將(分支)合併到當前分支 git merge 分支名 ex:將dev合併到master -> git merge dev(當前在master)
刪除分支 git branch -D 分支名
禁用Fast forward模式merge dev到當前 git merge --no-ff -m "描述" dev