便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网

这篇具有很好参考价值的文章主要介绍了便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

介绍

Want to easily manage your source code and collaborate with others? Git and GitHub are the tools you need! And with Visual Studio Code, you can set up and use them in a snap. Even if you’re a beginner, VS Code’s user-friendly interface guides you through common Git actions like pushing and pulling code, creating and merging branches, and committing code changes. And if you’re a pro, you’ll love the ability to perform Git actions directly within the editor, saving you time and effort compared to using the Git command line. Plus, the seamless workflow between VS Code and Git means you can stay in your editor and get more done.

在Vscode中启动Git

想要在Vscode中使用Git或者是Github,你需要首先确保安装了Git,然后再启动VS Code。
另外,你需要在VS Code中登录你的github账号,并对同步设置(Settings Sync)一下,而且克隆(cloning)并发布(publishing)一个仓库。

打开一个Git 仓库

VS Code 提供了多种方式打开Git 仓库:本地或者利用云端远程打开。

本地克隆(clone)打开

便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,git
To clone a repository from GitHub, execute the Git: Clone command or select the Clone Repository button in the Source Control view. If you clone from GitHub, VS Code will prompt you to authenticate with GitHub. This allows you to search all available repositories and clone private repositories. For other Git providers, enter the repository URL and select Clone and pick a folder. VS Code opens the folder once the repository is cloned on your local machine.

在本地初始化一个仓库

To initialize a new local repository, pick an existing or new folder on your computer and open it in VS Code. In the Source Control view, select the Initialize Repository button. This creates a new Git repository in the current folder, allowing you to start tracking code changes.

便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,git

发布一个本地仓库到 github

一旦你有了一个本地仓库,你就可以发布到Github。这将会在你的github账号上创建一个新仓库,并且将你的本地代码push到远程仓库。
Use the Publish to GitHub command button in the Source Control view. You can then choose a name and description for the repository, and whether to make it public or private. Once the repository has been created, VS Code will push your local code to the remote repository. Your code is now backed up on GitHub, and you can start collaborating with others with commits and pull requests.

在代码空间中(Codespaces)打开一个Github仓库

GitHub Codespaces let you open a GitHub repository in a full configured cloud-based development environment, allowing you to develop in a browser without having to install any software on your local computer.

Install the GitHub Codespaces extension into VS Code and sign in with GitHub. Run the Codespaces: Create New Codespace command and pick the repository and branch you want to open. The new codespace will open in a new window.
便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,git便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,git

远程打开一个Github仓库

VS Code’s remote repository support allows you to browse and edit a GitHub repository without cloning it to your local computer.支持远程仓库可以让用户不用克隆仓库到本地计算机。

First install the GitHub Repositories extension. Run the command Remote Repositories: Open Remote Repository… or use the Open Remote Repository button the Explorer view. Search and select the GitHub repository that you want to open.

Tip: If you need to execute code or run terminal commands, you can seamlessly switch from a remote repository to a codespace with the command Continue Working on.

Staging and committing code changes

便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,gityou can start tracking code changes by staging and committing your newly created and edited code. 跟踪

Tip: Commit your changes early and often. This will make it easier to revert back to previous versions of your code if needed.
经常提交commit,更有利于在需要的时候返回到先前版本。

To stage a file, select the + (plus) icon next to the file in the Source Control view. This will add the file to the Staged Changes section, indicating that it will be included in the next commit. Staged changes can also be discarded by selecting the − (minus) icon next to the file.

To commit your staged changes, type a commit message in the upper text box and select the Commit button. This saves your changes to the local Git repository, allowing you to revert to previous versions of your code if needed. You can navigate through and review all local file changes and commits in the Timeline view available in the bottom of the Explorer.
便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,git

Pushing and pulling remote changes

便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,gitOnce you have made commits to your local Git repository, you can push them to the remote repository. The Sync Changes button indicates how many commits are going to be pushed and pulled. Selecting the Sync Changes button downloads (pull) any new remote commits and uploads (push) new local commits to the remote repository.

Tip: You can enable the Git: Autofetch setting to always get an up-to-date remote commit indicator.

Push 和 pull 也可以分开使用

使用分支

便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网,开发,vscode,git

Tip: If you use the GitHub Pull Requests and Issues extension, you can create a branch directly from an issue, which gets you started working in a new local branch and automatically prefills the pull request for you.文章来源地址https://www.toymoban.com/news/detail-796980.html

到了这里,关于便捷开发技巧——在Vscode中使用Git-翻译自Vscode官网的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • VSCode使用技巧

    使用快捷键Ctrl+Shift+P 主题先选择 浅色+ (默认浅色) 然后选择setting workbench.colorCustomizations 选项是配置护眼色选项,个人比较喜欢豆沙绿#C7EDCC(还有青草绿 #E3EDCD、海天蓝 #DCE2F1、杏仁黄 #FAF9DE等),可根据个人喜好更换成不同的颜色。 其他的配置选项具有注释,可根据情况

    2024年01月16日
    浏览(48)
  • vscode C++17便捷配置教程(懒人版)

    环境链接 以上是已经配置好的c++17环境链接,直接下载解压即可(注意文件路径上不要带有中文) 下载解压之后按照msys64-mingw64-bin路径打开 然后单击该路径右方空白区域可直接复制路径  然后点击开始菜单搜索“环境变量“并打开(如图)  然后点击右下方环境变量 之后双

    2024年02月11日
    浏览(19)
  • 12.(开发工具篇vscode+git)vscode 不能识别npm命令

    问题描述: 解决方式: (1)右击VSCode图标,选择以管理员身份运行; (2)在终端中执行get-ExecutionPolicy,显示Restricted,表示状态是禁止的; (3)这时执行set-ExecutionPolicy RemoteSigned; (4)此时再执行get-ExecutionPolicy,显示RemoteSigned,则表示状态解禁,可以运行 (5)重启

    2024年02月16日
    浏览(29)
  • vscode——VScode中增加翻译插件

    Comment Translate 用法 选中自动翻译,很简单。 其他 这款插件还配有自动翻译功能,但不是特别灵敏好用,按 Ctrl + Shift + P 输入 translate 选择翻译选区即可。 ps:选择源不要选择谷歌,选择bing比较稳定

    2024年02月11日
    浏览(35)
  • 深入讲解VsCode各场景高级调试与使用技巧

    VsCode自从诞生以来,以其各自优异的特性迅速走红。尤其是对于前端开发小伙伴来说,几乎成为必不可少的开发工具。所以,熟练掌握VsCode的各自使用技巧与调试技巧会让你的日常开发工作效率倍增。本文将会以大量图文的方式,从下面几个方面详细介绍VsCode的各种技巧:

    2024年02月06日
    浏览(42)
  • VSCode使用技巧,代码编写效率提升2倍以上!

    VSCode是一款开源免费的跨平台文本编辑器,它的可扩展性和丰富的功能使得它成为了许多程序员的首选编辑器。在本文中,我将分享一些VSCode的使用技巧,帮助您更高效地使用它。 1. 插件 VSCode具有非常丰富的插件生态系统,通过安装插件可以为编辑器增加更多的功能。以下

    2024年02月03日
    浏览(41)
  • 用vscode仿制小米官网

     

    2024年04月16日
    浏览(29)
  • 在VSCode中使用LaTex+(grammarly语法检测,chatgpt翻译,Sumatra PDF 轻量级pdf阅读器)

    整个文章分为以下几个内容,打 * 的是必须要安装的 latex的下载安装可参考:LaTex(2021)安装教程 VSCode下载:VSCode官网 VSCode的安装非常简单,几乎不需要什么操作 先把中文包下载下来,重启生效 下载 LaTex Workshop 下载完之后,在界面下按下 Ctrl+Shift+P,然后键入“setjson”,点

    2024年02月06日
    浏览(51)
  • 下载安装各种版本的Vscode以及解决VScode官网下载慢的问题

    下载指定版本 在Vscode官网 Vscode官网更新子页 这里的左侧栏点击其中一个会跳转到某个版本,或者在官网子页 https://code.visualstudio.com/updates的后面跟上需要的版本号即可完成目标版本下载页面的跳转 选择Linux里的ARM包不会自动下载而是跳转到另一个页面 下载包的格式 URL链接

    2024年02月05日
    浏览(48)
  • vscode markdown 使用技巧 -- 如何快速打出一个Tab 或多个空格

    背景描述:         我在使用VSCode,这玩意很好用,但是,有一个缺点是,我想使用Tab来做一些对齐,但是我发现在VSCode中,无论是Tab还是多个空格,最终显示出来的都是一个空格         使用代码可以实现打印Tab或是多个空格:`emsp;` 对应一个tab         但是我发现想要

    2024年02月06日
    浏览(53)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包