2017-04-12 94 views
2

我創建了一個本地項目與Visual Studio代碼,實現本地Git倉庫VS代碼 - 連接到遠程Git倉庫,推動本地文件到新的遠程倉庫

然後我對Visual Studio的在線創建一個Git倉庫,我想我所有的項目文件推送到遠程倉庫...

什麼是正確的方法去做呢?

git的\ CONFIG文件在這一刻是這樣的:

[core] 
    repositoryformatversion = 0 
    filemode = true 
    bare = false 
    logallrefupdates = true 
    ignorecase = true 
    precomposeunicode = true 

謝謝支持

回答

15

我假設你開始在一個目錄下工作,並沒有使用git那裏。以下應用git bash的工作:

cd "path to your repo" 
git init 
git add . # if you want to commit everything. Otherwise use .gitconfig files 
git commit -m "initial commit" # If you change anything, you can add and commit again... 

要添加遠程,只是做

git remote add origin https://... 
git remote show origin # if everything is ok, you will see your remote 
git push -u origin master # assuming your are on the master branch. 

-u設置上游參考和git從哪裏fetch/pull知道和在哪裏push在未來。

+0

謝謝Christoph,我將是唯一一個將訪問存儲庫的人,我不需要確定創建分支。 那「起源」在第一行,什麼表示? – DarioN1

+1

它只是整個地址的縮寫。你可以給它任何名字,但如果他們只有一個遠程地址,大多數人稱它爲「origin」。你應該閱讀[this](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes);-) – Christoph

+0

謝謝,只是另一個簡單的問題:這是一個正確的程序定義本地存儲庫,複製這些文件,然後運行您提供的命令來發布遠程存儲庫上的文件? 或者有更好的方法來做到這一點? – DarioN1

相關問題