preface

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

The premise to prepare

1. You should have a GitHub account first, or sign up if you don’t

2. Install Git.

3. Have a Project you can throw on Github (this seems like crap)

4. Now that you’ve done all the above steps, let’s get started

Local repository

Basically, where your project is located

Go to the project folder

1. Find where the project is stored, and then type the open project folder (as shown in the picture) :

Open the Git Bash

Git Bash Here, Git GUI Here, Git Bash Here

After opening Git Bash

Setting User Information

This information will be used every time you commit with Git

$ git config --global user.name "name"
$ git config --global user.email "[email protected]"
Copy the code

What is the use of setting user.name and user. email?

It is used for identification, the open source community, sometimes the code is maintained by more than one person, maybe a team, then the submission of the code is not just an individual submission (if it is managed by an individual, say another word), these two parameters tell you who committed the code.

For example, in a company, people on the team write the code and maintain the code, and when you write the code, you have to know who wrote the code, and when you write the code, you hand it in and it crashes, and they don’t call you

Git initialization

  • To view the current configuration, run the following command:
$ git config --list
Copy the code

The screenshot contains only partial information (the information is too long to complete)

  • The next step is to create a new Git repository

The command is as follows:

$ git init
Copy the code

Git turns this path into a repository

After that, you cannot change the name of the current folder, or you will get an error

The Git repository is empty at this point, even if there are other nights, but only locally

If you do not delete git repositories, skip this step:

Now that I have created a git repository, I would like to delete the git repository and start it again.

The command is as follows:

$ rm -rf .git 
Copy the code

Viewing the Current Status

The command is as follows:

$ git status
Copy the code

Add the project file to the staging area of the local repository

The command is as follows:

$ git add README.md
Copy the code

An error is reported:

This command will not automatically create a new file that does not already exist, so you need to add a readme. md file to your project

After creating it, run the command again and check git status

To test it, the results are as follows:

Ok, now the readme.md file is done

Add files to the staging area

To add all files in the current directory to the staging area, use the following command:

$ git add .
Copy the code

Note: Add has a dot after it

But it’s not that simple

After entering this command, the following error appears:

To resolve the problem, run the following command:

$ git config --global core.autocrlf false
$ git config --global core.safecrlf fa'l
Copy the code

After running the add command, there is nothing wrong (too hard)

SAO operation again

  • What if you put something in there that you shouldn’t have!

Then delete the files you accidentally put there

The command is as follows:

$ git reset HEAD -- xxxxx # XXXXX for the files you accidentally put in
Copy the code

Or:

$ git rm -r --cached xxxx 
Copy the code
  • Originally do not want to put XXXXX file, except XXXX file, other need to add, how to do

Use the ignore file **.gitingore** and write the files you don’t want to add to the.gitinore file.

Submit files from the staging area to the local repository

The command is as follows:

$ git commit -m "first commit"
Copy the code

-m Parameter Description

What did you commit or change this time

Create a SSH KEY

The local Git repository and Github repository are encrypted by SSH, so SSH keys are required when linking

Before creating an SSH KEY, check to see if your computer has created an SSH KEY

Location: C:\User \ username \

Let’s see if it’s in this directory. SSH directory, there are two files, if not, create

The command is as follows:

$ ssh-keygen -t rsa -C "[email protected]"
Copy the code

Then keep pressing Enter, and you’ll have your.ssh file in your user directory

Add SSHKEY on Github

Log in to GitHub, go to the icon in the upper right corner, open Settings, then select SSH and GPG KEYS, title is not required, and copy all the contents from the.ssh directory — rsa.pub into the content box. Finally, click Add SSH Key

The steps are as follows:

Go to Settings and find SSH and GPG KEYS

Click:

Finally:

Making the warehouse

The new warehouse

To create a new repository on Github, do the following:

Once created, this screen will appear

Associate local and remote repositories

With the following command:

$ git remote add origin https://github.com/Hyaki-Amori/test.git
Copy the code

The address after Origin is the repository address you just created

Push local projects to remote repositories

The command is as follows:

$ git push -u origin master
Copy the code

Error:

Solutions:

Command:

$ git config --global http.sslVerify "false"
Copy the code

All right, we’re done!

Take a look at GitHub

Ok done