Check whether you have Git installed

The image above returns the git version number, indicating that Git has been installed. If it is already installed, proceed to Step 2. If not, please refer to git installation.Git installed

Configure Git

Git config --global user.email git config --global user.emailCopy the code

This step means that all git repositories on this machine will use this configuration.

Third, the establishment of local warehouse

Go to the folder you want to upload to Github, open a black window in that folder, and run git init

This allows ordinary folders to become local repositories. When you’re done, you’ll notice that there’s an extra.git file in that folder.

The file is usually hidden. If you don’t see it, don’t worry. The MAC system can display the file by performing the following operations:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Copy the code

Note: the.git folder is our local repository and is used by Git to manage tracking. Do not touch anything in this folder.

Set up a remote repository on Github

Open github and write the public key you used to install Git into SSH and GPG keys.

Where is the public key? Type open ~ /.ssh directly in the black window. Open the.ssh folder, id_rsa.pub, where the public key is stored.

Add: If no public key is available, generate it as follows:

// To create an SSH key, press ssh-keygen -t rsa -c "SSH key name can be email "// The default directory for saving SSH CD ~/.sshCopy the code

5. Connect local warehouse and remote warehouse

Git and Github are now connected, but how do you get the project to upload to the repository? This is where we need to add a remote repository so that our local projects can reach the corresponding repository smoothly.

In the black window type:

Git remote add Origin Specifies the location of the remote repositoryCopy the code

What is the remote warehouse address?

Six, upload the project

git status
git add .
git commit -m "my project"
git push origin master
Copy the code