Use git upload local files, folders to Github

 Upload files to use git github is particularly common, summarized below for reference.
Step One: Download git tool [link here] (https://git-scm.com/downloads), choose the version to install.

 

Step two: After the installation is complete, find the Git bash, double-click.

 

The third step: Enter your user name and mailbox (user name and mailbox registered GITHUB account)

$ git config --global user.name "[email protected]"
$ git config --global user.email "[email protected]"
1
2


Step four: Set up SSH key

  As we all know ssh is encrypted transmission. There are a lot of algorithms to encrypt transmissions, git can use rsa, rsa a core issue to be solved is how to use a particular pair of numbers that one of the numbers can be used to encrypt, and another number can be used to decrypt. These two figures is that when you use git and github encountered public key is a public key and a private key private key.

  Among them, the public key is used to encrypt the digital, which is why, after you generate a public key in the machine, to be uploaded to the cause github. From github sent back, encrypted with the public key that had the data, you can use the local private key to restore.

  If your key is lost, whether public or private, do not use the loss of one, the solution is simple, re-generated once and then set again in github.com on the line.

Closer to home, we first check whether the machine to generate a key, execute the command:

CD ~ $ / .ssh
$ LS
. 1
2
If the results were as follows, then the key already exists.

 

If there is no key, execute the following command to generate the key:

SSH-RSA keygen -t $ -C "[email protected]"
. 1
generation process is like pressing the Enter key three times (the default path, the default password is not), after the successful generation, in the default path to the corresponding with Notepad id_rsa.pub, get ssh key public key.

Step Five: Configure the SSH key to github account

  Next, switch to personal github account, click on the small triangle in the upper right corner of the user avatar, find the setting, found on the right side of the menu bar SSH and GPG keys, select the new SSH key, enter the title, the following key is the content of the machine ssh key public key, id_rsa.pub the content directly pasted on it, then click below to add SSH key to complete.

Step Six: Upload a file

1, create a local file


2, the establishment of local warehouses
(1) first into the layout folder:

 

(2) initialize execution instruction, generates a hidden file in the folder in the original folder .git:

Go $ init
1


(3) executing instructions to add the file to the local repository:

$ Git add. // add all files in the current folder
$ git add **. Cpp // ** Add the current folder. Cpp this file
1
2
Input (4) The submission instructions for submission temporarily has kept track of file changes in the area, enclosed in single quotes to illustrate the content:

$ Git -m content "layout" // quotes commit to the description file
1


3. Related github repository
in a new github repository, copy the warehouse address:

 

Excuting an order:

// The following code will appear when a new repository, you can directly copy the
$ git the Add Remote Origin https://github.com/CongliYin/CSS.git
1
2
Note:

If an error occurs: fatal: remote origin already exists, execute the following statement:

Origin git Remote RM $
1
and then re-run:

Remote git Origin https://github.com/CongliYin/CSS.git the Add $
1
to succeed.

Finally, execute the command:

Origin git push Master $
1
if there is an error failed to push som refs to ....... , Execute the following statement, first-come, first pull the remote server github above file, and then push up. :

$ git pull origin master
1


Refresh github, you can see the upload folder.
---------------------
Author: ColiYin
Source: CSDN
Original: https: //blog.csdn.net/sinat_20177327/article/details/76062030
Disclaimer: This article as a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/lezuw/p/11016632.html