Visual Studio Code - 连接到远程 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 存储库,我想推送我所有的项目文件到远程存储库...
Then I have create a Git repository on Visual Studio Online and I want to push all my project files to the remote repository...
正确的做法是什么?
我的 .gitconfig 文件此时如下所示:
My .gitconfig 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...
要添加遥控器,只需
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 Code - 连接到远程 Git 存储库并将本地文件推送到新的远程存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!