preface

This article is for Git, GitHub beginners to provide an introductory tutorial, will briefly describe the use of Git, GitHub and common skills. This article will help you create projects on GitHub and create a local repository with Git that connects to GitHub’s online repository.

Git installed

Git installation package url

Enter the website to download the corresponding version of your computer, directly install.

Making the registration

Making the website

Enter your user name, email address and password to register.

After registering, you can go to your home page and create your own project.

Generate and add SSH keys

The SSH key on GitHub can be simply understood as the ID of the local computer’s identity authentication. Therefore, you need to generate the local SSH key through Git command line and add it to GitHub, which is convenient for downloading and uploading codes from GitHub in the future.

1. Generate an SSH key

1. Open Git Bash and enter ssh-keygen -o -t rsa -b 4096 -c “[email protected]” or ssh-keygen -t rsa -c “[email protected]” This is the command line for generating SSH keys. Enter the email address used for registering GitHub, clip < ~/. SSH /id_rsa.pub (this is the command line for copying SSH keys). C:\Users\username.ssh

2. Add an SSH key to GitHub

Click the user’s profile picture to enter setting

3. The test

ssh -T [email protected]

GitHub creates projects

Create your own project on GitHub

Click Start a Project

Follow the configuration information shown and click Create Repository

Git Clone local Clone

After successfully creating the project, we can copy the Clone URL of the project, and then Clone the project locally with the Clone command of Git Base to create the local project repository.

Git clone url

Once in the Test folder, you can see the file project created in GitHub’s Test project

Git Git

Finally, the common Git command is attached for your reference

  1. Remote warehouse related commands
Check out the repository: $gitclone[git url] $git remote add [name] [url] $git remote rm [name] $git remoteset$git pull [remoteName] [localBranchName: $git push [remoteName] [localBranchName]
Copy the code
  1. Branch Operations related commands
$git branch -r Create a local branch: $git branch [name] ---- $git checkout -b [name] : $git push origin [name] : $git push origin $git merge [name] ---- Merge the branch named [name] with the current branch-d[name] : $git push origin-d [name]
Copy the code
  1. Local projects connect to remote repositories
$git status (.) $git add. $git add. $git remote -v ($git remote) $git commit ($git remote) $git pull Origin Master To pull the remote repository project to the local project: $git pull Origin MasterCopy the code