VS Code - 连接到远程 GIT 存储库并将本地文件推送到新的远程存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43364233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VS Code - Connect to remote GIT repository and PUSH local files to new remote repository
提问by DarioN1
I have created a local projectwith Visual Studio Code that implements a local GIT repository.
我使用 Visual Studio Code创建了一个本地项目,该项目实现了本地 GIT 存储库。
Then I have create a GIT repository on Visual Studio Onlineand I want to PUSH all my project files to the remote repository...
然后我在Visual Studio Online上创建了一个 GIT 存储库,我想将所有项目文件推送到远程存储库...
What is the correct procedure to do it ?
这样做的正确程序是什么?
My .git\configfiles in this moment look like this:
此时我的.git\config文件如下所示:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
Thanks to support
感谢支持
回答by Christoph
I assume you started to work in a directory and didn't use git there. The following should work with git bash:
我假设您开始在一个目录中工作并且没有在那里使用 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...
To add a remote, just do
要添加遥控器,只需执行
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.
The -u
sets an upstream reference and git knows from where to fetch
/pull
and where to push
in the future.
该-u
设置的上游参考和git知道从哪里fetch
/pull
和在哪里push
的未来。
回答by prosti
It is now possible to set the origin from VS Code without command line typing:
现在可以在没有命令行输入的情况下从 VS Code 设置原点:
git remote add origin https://github.com/USR/REPO.git
From within VS Code you may CTRL+SHIFT+Pif you are on Windows and type remote
.
从VS代码中你可以CTRL+ SHIFT+ P,如果你是在Windows和类型remote
。
From there select Git: Add Remote
and you will have two steps:
从那里选择Git: Add Remote
,您将有两个步骤:
- Set
origin
for the remote name: - Add
origin
URL: https://github.com/USR/REPO.git
- 设置
origin
远程名称: - 添加
origin
网址:https: //github.com/USR/REPO.git