Git | Youth training camp notes


theme: condensed-night-purple

highlight: a11y-dark

This is the 13th day of my participation in the "Fifth Youth Training Camp" Companion Notes Creation Activity

Git common commands

git config --global user.name username set user signature

git config --global user.email mailbox setting user signature

  • git init initializes the local library
  • git status View the status of the local library
  • git add file name is added to the temporary storage area
  • git commit m "log information" file name submitted to the local library
  • git reflog view history
  • git log view version details
  • git reset hard version number version shuttle

branch operation

| command name | function | | --- | --- | | git branch branch name | create branch | | git branch -v | view branch | | git checkout branch name | switch branch | | git merge branch name | The branch merged into the current branch |

GitHub officially stated that from October 1, 2020, all new source code repositories created on the platform will be named "main" by default instead of the original "master".

Resolve branch merge conflicts

编辑有冲突的文件,删除特殊符号,决定要使用的内容
特殊符号:<<<<<< HEAD 当前分支的代码 ======= 合并过来的代码 >>>>>>>hot-fix
要合并的分支内容变了,未合并的分支内容不变

Save it after the deletion is complete, add it to the temporary storage area again, and submit it to the local library again ( note: at this time, the file name cannot be used when using the git commit command )

Github

Create a remote warehouse

New warehouse: new repository

The name of the remote library is generally the same as the local library

public, private

After the warehouse is successfully generated, the address is our remote library

Remote Warehouse Operations

| 命令名称 | 作用 | | --- | --- | | git remote -v | 查看当前所有远程地址别名 | | git remote add 别名 远程地址 | 起别名 | | git push 别名 分支 | 推送本地分支上的内容克隆到本地 | | git pull 远程库地址别名 远程分支名 | 将远程仓库对于分支最新内容拉下来后与当前本地分支直接合并 | | git clone 远程地址 | 将远程仓库的内容克隆到本地 |

克隆后会自动帮我们起别名origin 小结: clone会做如下操作。1、拉取代码。2、初始化本地仓库。3、创建别名

SSH免密登录

在 C盘 User 自己的账户下右键 git bash here,ssh-keygen -t rsa -C 自己的邮箱签名

注意是在C/User/账户名,然后连续按三下回车,这样就会生成 .ssh 文件夹,里面有私钥和公钥

cd .ssh 进入.ssh文件夹, ll 查看文件列表, cat id_rsa.pub 查看id_rsa.pub文件的内容, 将一大串进行复制, 之后在 gitee 上添加公钥, 自己起一个标题, 将复制的公钥粘贴, 这样我们可以借助 ssh 链接来拉取和推送代码,并且不需要进行登录。

Guess you like

Origin blog.csdn.net/weixin_50945128/article/details/129377823