Git installation and key generation and uploading local files to GitHub

I used GitHub before, I am not very proficient, and I have encountered some problems during the uploading process. After reading many tutorials on the Internet, I always feel that it is very messy. I refer to some materials and summarize a complete operation step, from downloading and installing to uploading. file, pro-test is valid


1. Download Git software: https://git-scm.com/downloads

2. Install git software (very easy). After the installation is successful, in [Start]->[Programs]->[git], you will see Git Bash and Git GUI, open Git Bash, and enter the bash interface.

Next is the key point, if this step is not passed; if the secret key is not authenticated, the file cannot be uploaded, this has already been stepped on, and it has been prompted in English to tell who are you;

3. Register email

Enter the following in the git bash interface to complete the mailbox registration:

$ git config --global user.name "user.name"

(Note: You need your user name in double quotes, you can enter it casually, such as "wangting")

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

(Note: You need to enter your valid email address in double quotation marks, such as "[email protected]")

4. Check if ssh keys exist

$ cd ~/.ssh

If "No such file or directory" appears, it means that an ssh key needs to be created.

My secret key has been set up as follows:

5. If not set, create new ssh keys, otherwise git cannot upload files

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

$Specify directory: C:\MykeysForGit\ (Note: If you do not enter the path here, but press Enter directly, the path stored after ssh keys is generated is C:\User\.ssh)

$Enter password: 123456

$Confirm Password: 123456

This will generate ssh keys in the C:\MykeysForGit\ folder. Include two files rd_rsa and id_rsa.pub

6. So far, the installation of git software and the generation of keys have been completed. After that, you need to use the ssh keys used in SourceTress or GitHub or GitLib software to copy and copy the two files id_rsa and id_rsa.pub here.

===========================I am the dividing line====================== ====================

Start uploading local files to git:

1. Go to the directory of the uploaded file and use the command to initialize the local warehouse git init

2

Adding local files to the local warehouse staging area, . means adding and managing all files and subdirectories in the current directory, or you can replace . with the corresponding file name git add . or git add [filename]

3

Submit the files in the staging area of ​​the local warehouse to the local warehouse git commit -m 'ting'

4

Associate the local warehouse with the remote warehouse, where origin is the alias of the remote warehouse, which can be changed by yourself. git remote add origin [url] such as: git remote add origin https://github.com/wangxiaoting666/shasha.git

5: This step can be omitted

If the remote repository is not empty, synchronize the local repository with the remote repository. Otherwise, this step can be omitted, where master is the branch name of the remote warehouse. git pull --rebase origin master: (ps: If there is already a project in the warehouse, and if there is a conflict when uploading the project to this warehouse, use the command: git push --set-upstream origin master)

6

Synchronize the files in the local repository to the remote repository. where master is the branch name of the remote repository. git push -u origin master

Enter the github account and password:



7

Finally, you can use the command to view the status

git status

8. Complete, view the uploaded files:

Friendship link: http://www.cnblogs.com/xuange306/p/6403907.html

Welfare at the end of the sentence:

Benefit 1: A collection of 10G resources such as front-end, Java, product manager, WeChat applet, Python, etc. will be released :

Welfare 2: A full set of detailed video tutorials for WeChat mini-program introduction and actual combat.


【How to receive】

Pay attention to [Programming Micro Journal] WeChat public account:

Reply to [Mini Program Demo] One-click to receive 130 Wechat Mini Program source code demo resources.

Reply [Receive resources] One-click to receive front-end, Java, product manager, WeChat applet, Python and other resource collections 10G resources to be released.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325703827&siteId=291194637