Home  >  Article  >  Development Tools  >  How to use github in vscode

How to use github in vscode

王林
王林Original
2019-11-09 14:25:124596browse

How to use github in vscode

1. Download and install git and add the path to the environment variable. Enter

git --version

. If the version number is displayed, the installation is successful.

2. Create a new warehouse on github. For example: myrepo

3. Create a new folder locally as the working folder of the VSCode code. For example: mycode

4, mycode is both the code working folder of VSCode and the local Git repository. Enter mycode in command line mode. Enter git init

git init

5 and add your username and email address. The username and email address are the ones used when registering GitHub:

git config --global user.name "myname"
 
git config --global user.email "myname@mymail.com"

6. Generate a key. Continue to enter in this directory:

ssh-keygen -t rsa -C "myname@mymail.com"

After the command is executed, a file named id_rsa.pub will be generated. Open the file with a text editor and copy the full text.

7. Open the myrepo warehouse on github. Enter settings, set deployment keys, and paste the contents of id_rsa.pub into it. By default, the title corresponding to this key is myname@mymail.com.

8. Bind the local folder and the github repository

git remote add mycode git@github.com:myname/myrepo.git

9. After the setting is completed, perform a connection test

ssh -T git@github.com

10. First pull in sequence, and then proceed Push in turn.

git pull mycode master
git push --force mycode master

11. After the above configuration is completed, you can use VSCode to open the mycode folder to perform related operations. At this time, for any changes that occur in the folder, the number of the corresponding changed file will appear on the "Source Code Management" icon of VSCode. After clicking the "Source Code Management" picture, all changed file names will be listed. Click... in the upper right corner to perform the "Submit" operation.

12. After the submission is completed, check the GitHub myrepo for corresponding changes. If there is no change, open the console (ctrl `) in VSCode and select "Output" to see if there are relevant error prompts and make adjustments according to the error prompt information.

Recommended tutorial: vscode tutorial

The above is the detailed content of How to use github in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn