GitLab 和 Visual Studio 代码

Wil*_*tti 5 git gitlab visual-studio-code

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

在谷歌搜索期间我没有找到任何对我有帮助的东西,所以我在这里问。

我怎样才能集成它?

我正在使用 GitLab 的免费帐户,我想通过 Visual Studio Code 提交、推送和克隆。是否可以?

BiN*_*ZGi 5

Marketplace中,您可以找到很多Visual Studio Code 扩展。它们贴有标签,例如

\n\n

使用哪个取决于您的喜好和场景。我推荐并且我个人正在使用GitLens \xe2\x80\x94 Git supercharged

\n

对于 GitLens,Visual Studio Code 中的安装很简单,例如:

\n
\n

启动 VS Code 快速打开 (Ctrl+P),粘贴以下命令,然后按 Enter。

\n

ext install eamodio.gitlens

\n
\n

您在扩展页面上找到的文档,请参阅上面的链接。

\n


小智 5

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

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

git config --global user.name "xx xxxx"
git config --global user.email "xx.xxxx@mail.com"
Run Code Online (Sandbox Code Playgroud)

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

然后,由于您要在 GitLab 中创建一个新的远程存储库(例如在 NewFolder 中,以repo.git作为 Git 名称),请输入:

git clone ssh://git@gitlab.com/NewFolder/repo.git
Run Code Online (Sandbox Code Playgroud)

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

cd repo
Run Code Online (Sandbox Code Playgroud)

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

提交后,您可以通过 Visual Studio Code 界面发布它。

或者手动输入:

git add .
git commit -m "Initial commit"
git push -u origin master
Run Code Online (Sandbox Code Playgroud)