2015-10-04 32 views
1

我最近在我的機器上重新安裝了Ubuntu,並對所有文件和文件夾進行了備份。我正在使用PyCharm將本地文件與bitbucket上的存儲庫同步。我已經看到了很多關於如何爲NEW存儲庫執行此操作的教程,但是如果您的項目已經存在,那麼我沒有看到如何執行此操作,而且您已經在項目中存在.git文件。當你有一個以前的.git文件的項目文件夾時如何設置bitbucket?

我已經下載到位桶插件,設置我的遙控器,並測試了連接,但我不斷收到這個錯誤,當我試圖把文件:

Commit failed with error: 
On branch master 
Changes not staged for commit: 
    modified: Detection-alf/loadTrainingImages.py~ 
    modified: automated-detection-for-alf/bibsmart_auto_detector.py~ 
    modified: automated-detection-for-alf/bibsmart_verify_csv.py~ 

這是我所得到的,如果我做的git推

[email protected]:~/Dropbox/Alfredo1/Caffe$ git push 
Username for 'https://bitbucket.org': alfredox10 
Password for 'https://[email protected]': 
To https://bitbucket.org/alfredox10/bibsmart_detection 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to 'https://bitbucket.org/alfredox10/bibsmart_detection' 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Integrate the remote changes (e.g. 
hint: 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

我做了git拉,並再次嘗試。

[email protected]:~/Dropbox/Alfredo1/Caffe$ git pull 
Cannot pull with rebase: You have unstaged changes. 
Please commit or stash them. 

但是我不得不隱藏所做的修改。

[email protected]:~/Dropbox/Alfredo1/Caffe$ git stash 
Saved working directory and index state WIP on master: df3e5e0 terminal git test commit 
HEAD is now at df3e5e0 terminal git test commit 

最後我做了git pull,使我的本地文件與服務器上的文件相同。

[email protected]:~/Dropbox/Alfredo1/Caffe$ git pull 
Username for 'https://bitbucket.org': alfredox10 
Password for 'https://[email protected]': 
From https://bitbucket.org/alfredox10/bibsmart_detection 
* branch   master  -> FETCH_HEAD 
Auto packing the repository for optimum performance. You may also 
run "git gc" manually. See "git help gc" for more information. 
Counting objects: 159251, done. 
Delta compression using up to 8 threads. 
Compressing objects: 100% (159214/159214), done. 
Writing objects: 100% (159251/159251), done. 
Total 159251 (delta 15072), reused 0 (delta 0) 
Removing duplicate objects: 100% (256/256), done. 
fatal: Needed a single revision 
invalid upstream 24c9aac9a2eccf4313835cf89f7ece050e049d46 

我做了git再次推,現在我仍然得到這個。

[email protected]:~/Dropbox/Alfredo1/Caffe$ git push 
Username for 'https://bitbucket.org': alfredox10 
Password for 'https://[email protected]': 
To https://bitbucket.org/alfredox10/bibsmart_detection 
! [rejected]  master -> master (fetch first) 
error: failed to push some refs to 'https://bitbucket.org/alfredox10/bibsmart_detection' 
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. 
+0

我只是建議從命令行使用複製粘貼指令來做到這一點,當你通過網絡創建一個新的項目時,Bitbucket會給出它。 –

+0

我做到了,仍然不幸。 – alfredox

+0

您推送的存儲庫不是空的。 –

回答

0

你要他們先添加這些文件,並提交和推動他們:

git add . 
git commit -m 'Your commit message' 
git push 

然而,我想他們是臨時文件的文件名,你你最好刪除和忽略它們(在.gitignore):

*~ 

此外,像@MikkoOhtamaa評論,你可以創建一個新銷售代表ository:

如果這些文件是相同的,只需從頭開始重新創建一個新的存儲庫。這是最簡單的解決方案。 - Mikko Ohtamaa 23小時前

+0

我修改了帖子,嘗試了一些你告訴我的內容,以及我在網上找到的其他內容。 – alfredox

+0

@alfredox好吧,我們將一步步做到:現在'git status'的輸出是什麼? –

+0

>關於分支主人 >未針對提交進行更改: >(使用「git add ...」更新將提交的內容) >(使用「git checkout - ...」「丟棄在工作目錄的變化) > > \t改性:.idea/workspace.xml > >沒有改變加入到提交(使用 」GIT中增加「 和/或 」git的承諾-a「) >阿爾弗雷@ alfpc-ubuntu:〜/ Dropbox/Alfredo1/Caffe $ – alfredox

相關問題