把目前使用中,而且沒有git的資料夾track remote branch
- 連線的PC or server要有SSH Key, 並且把Public key的內容貼到Bitbucket的Repo設定裡
Step by step tutorial: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
- ssh-keygen
- Press the Enter or Return key to accept the default location. (Or leave it empty)
- Enter and re-enter a passphrase when prompted.
- ls ~/.ssh id_rsa id_rsa.pub
- eval
ssh-agent
1eval `ssh-agent` - ssh-add ~/.ssh/<private_key_file>
- cat ~/.ssh/id_rsa.pub
- Paste public key to bitbucket
- Git commands to track remote branch
- git init
- git add .
- git commit -m ‘Init git’ (Current branch is master)
- git remote add origin git@gitserver:/opt/git/project.gitReference
or
1git branch --set-upstream-to=origin/master master
- git fetch
- git branch -u origin/master
Fix “detached HEAD” error
https://gitbook.tw/chapters/faq/detached-head.html
Fix “refusing to merge unrelated histories” error:
- Force pull
1git pull origin master --allow-unrelated-histories
- Fix conflicts maybe. Uploading files with conflicts by FTP could be the fastest solution.
- git add .
- commit
- Done
Note: 執行完上方command後,兩方client有不同步或是持續出現conflict的問題,重覆修正幾次之後就好了。原因不明。 Reference: