寫這篇博文的原因
寫這篇博文,是因爲自己在使用Git的過程中,着實遇到了很多問題,現在記錄下來,一是爲了避免以後犯同樣的錯誤,二是給其他人一些參考。
使用TortoiseGit
1.在有一次使用TortioseGit的過程中,我遇到了這樣的問題:
Username for ‘https://github.com‘: dummymare
Password for ‘https://[email protected]‘:
To https://github.com/dummymare/Hello-World.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/dummymare/Hello-World.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
出現這種情況,一般是因爲:本地版本和主幹上的有差異。。。讓你先pull遠端的版本,解決了衝突才能push。比如說,當時我的情況是,在Github新建了一個代碼庫,同時初始化了一個README.MD,建好之後,我馬上就從本地Push代碼,就出現了這個問題。我的解決辦法是,pull遠端的README.MD,然後再Push,就沒有問題了: