Git usage record 1: upload project to GitHub using Git

Time:2020-10-21

1. Install Git

Git website

The specific operation is omitted

2. Configure GitHub repository

1. Create warehouse

Git usage record 1: upload project to GitHub using Git

2. Copy warehouse address

Git usage record 1: upload project to GitHub using Git

3. Configure the key of GitHub server

Because git uses SSH connection, and the first SSH connection needs to verify the key of GitHub server. Confirm whether the fingerprint information of GitHub’s key really comes from GitHub’s server. terms of settlement. In fact, the key is generated locally and configured to GitHub server.

1) . use the command LS – Al ~ /. SSH in Git bash
Git usage record 1: upload project to GitHub using Git

2) Use the command: SSH keygen – t RSA – C “GitHub user name”, press enter three times
Git usage record 1: upload project to GitHub using Git

3) View the generated key: cat ~ /. SSH / ID_ rsa.pub
Git usage record 1: upload project to GitHub using Git

4) Log in to GitHub and copy the newly generated SSH configuration to the server,

Git usage record 1: upload project to GitHub using Git

Git usage record 1: upload project to GitHub using Git

4. Upload local project

1) : open git bash, CD to enter the address where you put the project file. My address is in the D: xxxxx project
Git usage record 1: upload project to GitHub using Git

2) : enter git init, which means to generate local git management in the current project directory (you will find that there is an extra. Git folder in the current directory)
Git usage record 1: upload project to GitHub using Git

3) Enter git add
Git usage record 1: upload project to GitHub using Git

4) Enter git commit – M “test” to indicate your comments on this submission. The contents in double quotation marks can be according to personal needs
Git usage record 1: upload project to GitHub using Git

5) If the following content appears here, you need to enter your own account or name
Git usage record 1: upload project to GitHub using Git

6) Use the code shown above to enter your email address or name
Git usage record 1: upload project to GitHub using Git
Git usage record 1: upload project to GitHub using Git

7) If you type git commit – M “test”, it will succeed
Git usage record 1: upload project to GitHub using Git

8) Upload to GitHub remote repository
Git remote add origin [email protected] : test.git
git push -u origin master
Git usage record 1: upload project to GitHub using Git
Note that if the upload fails here

The main cause of the error is in GitHub README.md The file is not in the local code directory

[](https://link.jianshu.com?t=http://jingyan.baidu.com/album/f3e34a12a25bc8f5ea65354a.html?picindex=4)

[](https://link.jianshu.com?t=http://jingyan.baidu.com/album/f3e34a12a25bc8f5ea65354a.html?picindex=4)

Code merging can be performed through the following command [Note: pull = fetch + merge]

git pull –rebase origin master

[](https://link.jianshu.com?t=http://jingyan.baidu.com/album/f3e34a12a25bc8f5ea65354a.html?picindex=5)

[](https://link.jianshu.com?t=http://jingyan.baidu.com/album/f3e34a12a25bc8f5ea65354a.html?picindex=5)

After executing the above code, you can see that there are more in the local code base README.md file

[](https://link.jianshu.com?t=http://jingyan.baidu.com/album/f3e34a12a25bc8f5ea65354a.html?picindex=6)

[](https://link.jianshu.com?t=http://jingyan.baidu.com/album/f3e34a12a25bc8f5ea65354a.html?picindex=6)

At this point, execute the statement git push – U origin master to upload the code to GitHub

reference resources
Git usage record 1: upload project to GitHub using Git

be careful

1. LF will be replaced by CRLF in the GIT commit code
The reason is that the file to be submitted is generated under windows. The line feed character in windows is CRLF, while that in Linux is lf. Therefore, a prompt appears when you execute add. Solution: git config — global core.autocrlf False and then execute git submission
2、fatal: sha1 file ‘<stdout>’ write error: Broken pipe
Git push has a problem: it’s about the size of the file! Because the default size of GitHub is 100m, if your file is larger than 100m, then you cannot succeed. This will appear: fatal: fatal: SHA1 file ‘< stdout >’ write error: broken pipe the remote end hung up unexpected error
The solution is git config http.postBuffer 428800 in size