Tag Archives: SourceTree

Common Git Command

新公司是用Git
很多同事都是使用Git BashCommit/Pull/Push source 去Bitbucket
由於不太懂Git command的關係
所以我便用BitbucketSource Tree..
可能是太多Projects/ Repositories
久不久..我的Source Tree 便出現問題..
之前還試過

以下是一些常用的 Git Command

//用來提取這個repository 的最近資料

git fetch

// 用來checkout branch

git checkout [branch name]

// 用來Pull 最新的 current branch

git pull 

// 加 unstage 的 file

git add *

// 或一個一個檔案 stage
git add FileToStage

// commit

git commit -m "message"

//push

git push

// merge the specific branch to current

git merge develop

這會merge develop branchcurrent checkoutbranch

暫時分享住這些
有機會再share 其他常用的git command

Hope you find it useful

fetch origin error: cannot lock ref – Another git process seems to be running in this repository, e.g. an editor opened by ‘git commit’. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier

今日很䌓忙時候 我的Git / Source Tree 出現了以下的錯誤信息
可能是開了太多的ProjectLocal Branch 的關係

Another git process seems to be running in this repository

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
error: cannot lock ref ‘refs/remotes/origin/develop’: Unable to create ‘D:/Git/client-web/.git/refs/remotes/origin/develop.lock’: File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by ‘git commit’. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.”

解決方法十分簡單
我們只需要到這個Project 的 “.Git” 資料夾內
e.g.”/.git/refs/remotes/origin/

或出那個有 “.lock” Extension 的檔案.之後把他”刪除” 便可以了

Hope you find it useful

BitBucket SoureTree – The server’s host key is not cached in the registry

今天嘗試使用SourceTreePush一個新的Git Repos
誰不知 Push了很久都是停留在同一個output Windows
SourceTree Output Windows - The server's host key is not cached in the registry

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin master:master
Pushing to git@bitbucket.org:sharechiwai/SampleCode.git

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 97:xxxxxxxxxxxxxxxxxxxxxxx
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.

If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.

做了一會research之後終於找到解決方法了

解決方法:
大家可以使用Command Prompt之後輸入以下指令到 Source treePutty資料夾

cd "C:\Program Files (x86)\Atlassian\SourceTree\tools\putty"

之後執行以下指令到連接到 BitBucket

plink git@bitbucket.org

他便會出現上面的問題..叫你把Host Key CachRegistry
BitBucket SourceTree - The server's host key is not cached in the registry Solutions
完成後再嘗試使用Source Tree 去Push
這一次很快便可以把這一個Local Repos Push上了BitBucket

Hope you find it useful