2012年7月6日 星期五

git 相關

git error
fatal: unable to create 'abc/.git/index.lock' File exist.
If no other git process is currently running, this probably means a git process crashed in this repository earlier, Make sure no other git process is running and remove the file manual to continue.

Solution:
remove ../.git/index.lock
ex: rm -r ./.git/index.lock

git command
1. repo sync
2. repo start new_branch . (新增 branch)
3. git branch (確認branch狀態)
4. git branch -d branch_name( 刪除branch)
5. git diff > diff.txt ( 將有修改的檔名的不同處存下來)
6. git status (顯示所有有動變的檔案)
7. git commit -a
8. git show HEAD( show上一個commit 資訊)
9. repo upload . (實際上傳到server)

如果還要修改但還沒merge
1 git add .
2. git commit --amend
3. repo upload .

切換到別的branch
git checkout branch_name

將存下的 patch加入source code 之中(打 patch)
patch -R p1 < xxx.patch --dry-run

將檔案回歸到原始(server)狀態
git checkout -- filename

新增一個檔案
git add -p file_name(只加這一個檔案,有時路徑下有很多檔案修改,但只想上傳這一個)

新增 folder
git add folder_name(先新增folder, 才會出現此folder下的檔案)
PS. 如果新增一個空資料夾,必須在此資料夾加一個隱藏檔

取得git log並格式化
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"



沒有留言: