GitLab 和 Visual Studio 代码 [英] GitLab and Visual Studio Code

查看:79
本文介绍了GitLab 和 Visual Studio 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Visual Studio Code 集成为 GitLab 以执行源代码的版本控制.

I'm trying to integrate Visual Studio Code as GitLab to perform version control of source code.

我在 Google 搜索过程中没有找到任何对我有帮助的东西,所以我在这里问.

I did not find anything that would help me during the Google searches, so I'm asking here.

如何整合它?

我正在使用 GitLab 的免费帐户,我想通过 Visual Studio Code 提交、推送和克隆.有可能吗?

I'm using GitLab's free account and I want to commit, push, and clone through Visual Studio Code. Is it possible?

推荐答案

在 Windows 中,一旦 SSH 密钥在您的机器中设置好并且您安装了 Git(例如,Git-2.20.1-64-bit.exe),然后您需要在 Visual Studio Code 中设置 Git.

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 Visual Studio Code.

在 Visual Studio Code 的终端中,设置全局配置:

In the terminal of Visual Studio Code, set up the global configuration:

git config --global user.name "xx xxxx"
git config --global user.email "xx.xxxx@mail.com"

在同一终端中,导航到您要从 GitLab 设置远程存储库的本地目录.

In the same terminal, navigate to your local directory where you want to set up the remote repository from GitLab.

然后,因为您正在 GitLab 中创建一个新的远程存储库(例如,在 NewFolder 中,以 repo.git 作为 Git 名称)类型:

Then since you are creating a new remote repository in GitLab (e.g inside NewFolder with repo.git as the Git name) type:

git clone ssh://git@gitlab.com/NewFolder/repo.git

在同一个终端中,导航到新创建的名为repo"的本地文件夹:

In the same terminal, navigate to your newly created local folder called "repo":

cd repo

然后您可以将文件添加到该本地文件夹repo"中.然后在 Visual Studio Code 源代码控制按钮中,暂存更改并单击复选图标以提交它.

You can then add files into that local folder "repo". Then in the Visual Studio Code source control button, stage the changes and click the check icon to commit it.

一旦提交,您就可以通过 Visual Studio Code 界面发布它.

Once committed, you can then publish it via the Visual Studio Code interface.

或者手动输入:

git add .
git commit -m "Initial commit"
git push -u origin master

这篇关于GitLab 和 Visual Studio 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆