git GitLab 和 Visual Studio 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53525536/
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
GitLab and Visual Studio Code
提问by William Gustavo Marquetti
I'm trying to integrate the visual sutdio code as gitlab to perform version control of source codes.
我正在尝试将可视化 sutdio 代码集成为 gitlab 以执行源代码的版本控制。
I did not find anything that would help me during the google searches, so I'm asking here.
我在谷歌搜索期间没有找到任何对我有帮助的东西,所以我在这里问。
Has anyone managed to integrate?
有没有人设法整合?
I'm using GitLab's free account and I want to commit / push / clone through Visual Studio Code, is it possible?
我正在使用 GitLab 的免费帐户,我想通过 Visual Studio Code 提交/推送/克隆,这可能吗?
回答by BiNZGi
In the Marketplaceyou find a lot of Visual Studio Code Extensions. They are labeled with tags, e.g.
在Marketplace 中,您可以找到许多Visual Studio Code 扩展。它们标有标签,例如
Which to use depends on your preferences and scenarios. I recommend and I am personally using GitLens — Git supercharged.
使用哪个取决于您的偏好和场景。我推荐并且我个人使用GitLens — Git supercharged。
The installation in Visual Studio Code is easy, for GitLens e.g.:
在 Visual Studio Code 中安装很容易,对于 GitLens 例如:
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install eamodio.gitlens
启动 VS Code 快速打开 (Ctrl+P),粘贴以下命令,然后按 Enter。
ext install eamodio.gitlens
The documentation you find on the extension page, see link above.
您在扩展页面上找到的文档,请参阅上面的链接。
回答by DonAriston
In Windows, once ssh keys are settled in your machine and you have git installed (e.g. Git-2.20.1-64-bit.exe), you then need to setup the git inside VScode.
在 Windows 中,一旦 ssh 密钥在您的机器上确定并且您已经安装了 git(例如 Git-2.20.1-64-bit.exe),您就需要在 VScode 中设置 git。
In the terminal of VScode setup the global config:
在 VScode 设置的终端中,全局配置:
git config --global user.email "[email protected]"
In the same terminal, navigate to your local directory where you want to setup the remote repository from gitlab.
在同一个终端中,导航到要从 gitlab 设置远程存储库的本地目录。
Then since you are creating a new remote repository in GitLab (e.g inside NewFolder with repo.git as the git name) type :
然后,由于您要在 GitLab 中创建一个新的远程存储库(例如在 NewFolder 中,以 repo.git 作为 git 名称),请键入:
git clone ssh://[email protected]/NewFolder/repo.git
In the same terminal, navigate to your newly created local folder called "repo"
在同一个终端中,导航到新创建的名为“repo”的本地文件夹
cd repo
You can then add files into that local folder "repo". Then in the VScode source control button, stage the changes and click the check icon to commit it.
然后,您可以将文件添加到该本地文件夹“repo”中。然后在 VScode 源代码控制按钮中,暂存更改并单击复选图标以提交更改。
Once committed, you can then publish it via VScode interface.
提交后,您就可以通过 VScode 界面发布它。
or manually by typing:
或手动键入:
git add .
git commit -m "Initial commit"
git push -u origin master