Git version control details

Keywords: git github ssh Permission denied

GitHub operation process:

1. Create a new code base

$ git init
$ git clone [url]

2. Create branch

Administrator@UMMMZHE4GX4KT68 MINGW64 ~/Desktop/pythoncode/4.20/my.github.io (master)
$ git checkout -b xxz
Switched to a new branch 'xxz'

3. View status

Administrator@UMMMZHE4GX4KT68 MINGW64 ~/Desktop/pythoncode/4.20/my.github.io (xxz)
$ git status
On branch xxz
nothing to commit, working tree clean

Note: the master branch here changes to xxz

4. Modify the code

... operate by yourself here

5. Submit to cache

git add .   //Commit entire folder to cache
git add xxx  //Submit the modified file to the cache

6. Submit to GitHub

git commit -m 'xxx'//Add comments and descriptions
(git commit -am "annotation"addandcommitContinuous use)
6.git push origin xxx  //Upload branches to github

7. View, delete and switch branches

1.git branch
 2.git branch -D xxx delete local branch
  git push origin --delete xxx Delete remote branch
3.git checkout xxx

Note: you need to switch to another branch when deleting a branch

8. Set global user name

1.git config --global user.name "xxz199539"//
2.git config --global user.email "xxxxxxx@qq.com"

9. Set public key

When creating a new project clone project address because the public key and private key are not set:
$ git clone git@github.com:xxz199539/xxz.github.io.git
Cloning into 'xxz.github.io'...
key_load_public: invalid format
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
//At this time, you need to set the public key and private key, which are implemented by the following command:
ssh-keygen -t rsa -C 550276107@qq.com
$ ssh-keygen -t rsa -C 550276107@qq.com

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:SK7wvXyTDJ0EhmesI5B8OMjMfple+MxWbmDQ7a1DtjQ 550276107@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|*.. .o.          |
|+B o..*.         |
|..o ==o..        |
| ..=o* E..       |
|  +.*.XoS.       |
|   + B.*o        |
|    + oo..       |
|     . .=        |
|      o. .       |
+----[SHA256]-----+

In the / c/Users/Administrator/.ssh file, you can see an id_rsa and an id_rsa.pub file
Get remote branch, merge branch

git pull origin xxx get branch
 git merge merge branch

Version mark

git tag -a Version number -m "annotation"
 git push origin v4.20
 git tag(View current branch)
 git tag -d v4.20Delete local branch
 git push origin --delete tag v4.20Delete remote branch


 git show commit-id :View code submitted once
 git log View historical version
 git reset --hard xxx Back to a id Code

Posted by sader on Tue, 31 Mar 2020 03:51:02 -0700