How to upload local files to GitHub by Git

Step 1: Create a GitHub account

Create a GitHub account (where specific methods Baidu, not over the wall), then click on following your own avatar, select "Your repositories" as shown in Fig.
Here Insert Picture Description

Step 2: Create a warehouse

Click on "New" to create a new warehouse to store our local files
Here Insert Picture Description
to create detailed operation of the warehouse:
Here Insert Picture Description
At this time we have successfully created a test warehouse, we can see that only a readme file
Here Insert Picture Description

Step 3: Install Git

GitHub repository is created, then we need to install Git
(download link: https://git-scm.com/downloads )
direct the default option to install, operate a mouse right-click on the desktop after successful installation, you will see
" git GUI Here "and" git Bash Here "these two options, as shown below:
Here Insert Picture Description

Step Four: Create a new empty folder

Now we need to create an empty folder to manage those local files we need to be uploaded to GitHub, where I created a folder Github_test for testing.
Here Insert Picture Description
Then we open Github_test the empty folder, then right-click to select "Git Bash Here", then there will be a command window, as shown below:
Here Insert Picture Description

Step Five: Configure the user name and mailbox

To configure user and mailbox in the figure by two lines of instructions:
Here Insert Picture Description

Step Six: Get the key

Input ssh-keygen -t rsa -C "email address" , no space between the ssh-keygen, there is a space between the other.
After a carriage return, a line will appear, allowing you to enter a place to save the key, inside the brackets is it the default location, where the content will let you enter a few times, do not enter, hit enter on it , then you will "C: \ users \ username" to see this folder .ssh, if not see, because the file itself is hidden, as shown in Fig operate at this time you can see.
Here Insert Picture Description
In the .ssh folder you will see id_rsa and id_rsa.pub these two documents, the former is a private , not easy for others to see, which is open, we use Notepad to open id_rsa.pub this folder, Ctrl + A to select all the contents, then Ctrl + C to copy.

Step Seven: configure keys in the Github

We open Github, click on the picture to select "Settings", then select "SSH and GPG keys", there is a "New SSH key" button next to the SSH keys, click on it, Title part of their free to fill, key part of us will just copy paste the contents come in, then click on the Add SSH key can be.
Here Insert Picture Description
Then we need to verify whether the setting is successful, enter the following command at the bash git:
SSH -T [email protected]
If you are a first time, will let you enter yes or no, then yes you can enter, and then to see if there is the known_hosts file under this directory.

Eighth step: upload local files to the repository GitHub

I created a folder in Github_test a document ready to upload it to my GitHub repository, as shown below:
Here Insert Picture Description
Operation as follows:
① Open git bash at Github_test folder directory.

② input git init to complete the initialization work, then at Github_test folder there will be a folder named .git, and in front of the same .ssh folder is a hidden folder.
Here Insert Picture Description
③ Since the establishment of the warehouse when I created README.md, I need to look at the local synchronization of content repositories with the following command:
git pull https://github.com/Jacques-Yang/test.git
Here Insert Picture Description
Here Insert Picture Description
At this point you will see to more than a README.md, which means that the synchronization was successful.

④ Here I upload the file you just created should to go to the warehouse, the first implementation of the enhanced command, the command is as follows:
. Git add
later add a plus point, want to submit all the files, if you want to submit the specified file, you can add to that point later in the file name you want to replace the file submitted.
Here Insert Picture Description
⑤ After the completion of implementation of the enhanced command, to commit command, the command is as follows:
"Write down your current submission commit" git commit -m
Here Insert Picture Description
back with -m message, this message is sure to write both the rule, also help us record that we submitted, submitted know why or what has changed.

⑥ now continue to enter the following command in the terminal, increase our warehouse management to test created on the github.
git remote add origin https://github.com/Jacques-Yang/test.git
Here Insert Picture Description
Since I already had this, so there will be prompt.

⑦ The final step is to upload files to a GitHub repository, the following command:
git the Push Origin Master
Here Insert Picture Description
Because the file has been successfully uploaded to the test master branch in the warehouse.
Here Insert Picture Description
You have any questions you can leave comments area, we come together to explore Ha ha ha

Published an original article · won praise 1 · views 162

Guess you like

Origin blog.csdn.net/weixin_44421949/article/details/105394740