Will保哥Git基礎教學筆記

Git 最重要的是管控, 非原始碼備份

reset: 重置當時某個版本的source code,
-- hard: 強迫將local端資料庫與檔案目錄同步
-- mixin: 保留工作目錄, 指更新資料庫資料
checkout: 切換分支, 分支的位置不會改變, 取出檔案, 跳躍到某個時間點

註1:git commit會改變分支位置, reset會移動分支,

git log: 從分支的頭(最新版)畫到尾

註2: git 只有新增, 刪除與隱藏, 沒有覆蓋

分支就是指標

tags: 版本已經固定不動,
branch: 該版本還在更動

gitignore.io: 各個程式預設建立的gitignore

如何解決衝突

* 發生衝突, 立刻處理
* 解決衝突:
1. 放棄合併
2. 手動解決(文件內的Head====>)
3. 從gic commit 內決定(git resolve yours 或 mine)
4. 使用TortoiseGitMerge, 點擊衝突檔案, 修改內容

共用儲存庫:

用在沒有http的環境下, 可用在 dropbox. google drive

git cli 設定縮寫

git config –global alias.co checkout
git config –global alias.ci commit
git config –global alias.st status
git config –global alias.sts “status -s"
git config –global alias.br branch
git config –global alias.re remote
git config –global alias.di diff
git config –global alias.type “cat-file -t"
git config –global alias.dump “cat-file -p"
git config –global alias.lo “log –oneline"
git config –global alias.ll “log –pretty=format:’%h %ad | %s%d [%Cgreen%an%Creset]’ –graph –date=short"
git config –global alias.lg “log –graph –pretty=format:’%Cred%h%Creset %ad |%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset [%Cgreen%an%Creset]’ –abbrev-commit –date=short"

發表留言