Visual Studio代码-连接到远程Git存储库,并将本地文件推送到新的远程存储库 [英] Visual Studio Code - Connect to a remote Git repository and PUSH local files to a new remote repository
问题描述
我已使用Visual Studio Code创建了一个实现了本地Git存储库的本地项目.
I have created a local project with Visual Studio Code that implements a local Git repository.
然后我在 Visual Studio Online 上创建了一个Git存储库,我想将所有项目文件 push 到远程存储库中.
Then I have create a Git repository on Visual Studio Online and I want to push all my project files to the remote repository...
正确的操作步骤是什么?
What is the correct procedure to do it?
此刻我的 .git \ config 文件如下所示:
My .git\config files at this moment look like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
推荐答案
我假设您开始在目录中工作,并且未在其中使用Git.以下应该适用于 Git Bash :
I assume you started to work in a directory and didn't use Git there. The following should work with Git Bash:
cd "path to your repository"
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 you are on the master branch.
-u
设置上游参考,Git知道将来从fetch
/pull
到哪里以及从push
到哪里.
The -u
sets an upstream reference and Git knows from where to fetch
/pull
and where to push
in the future.
这篇关于Visual Studio代码-连接到远程Git存储库,并将本地文件推送到新的远程存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!