Detailed explanation of Git version control

GitHub operation process:

1. Create a new code base

$ git init
$ git clone [url]

2. Create a branch

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

3. Check the status

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

注意:这里的master分支变为了xxz

4. Modify the code

...这里自行操作...

5. Submit to the cache

git add .   //提交整个文件夹到缓存区
git add xxx  //将修改后的文件提交到缓存区

6. Submit to GitHub

git commit -m 'xxx'//添加注释和描述
(git commit -am "注解"addcommit连用)
6.git push origin xxx  //将分支上传到github

7. View branches, delete branches and switch branches

1.git branch
2.git branch -D xxx  删除本地分支
  git push origin --delete xxx  删除远程分支
3.git checkout xxx

注意:删除分支时需要切换到另外的分支

8. Set the global username

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

9. Set the public key

由于没有设置公钥和私钥,再新建项目克隆项目地址时:
$ git clone [email protected]:xxz199539/xxz.github.io.git
Cloning into 'xxz.github.io'...
key_load_public: invalid format
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
这时就需要设置公钥和私钥,通过以下命令实现:
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]-----+

You can see an id_rsa and an id_rsa.pub file in the /c/Users/Administrator/.ssh file
Get the remote branch and merge the branch

git pull origin xxx  获取分支
git merge 合并分支

version tag

git tag -a 版本号 -m "注解"
 git push origin v4.20
 git tag(查看当前分支)
 git tag -d v4.20删除本地分支
 git push origin --delete tag v4.20删除远程分支


 git show commit-id :查看某次提交的代码
 git log 查看历史版本
 git reset --hard xxx退回到某个id的代码

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326874191&siteId=291194637