linux:git
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| linux:git [2026/10/13 22:06] – 外部编辑 127.0.0.1 | linux:git [2026/10/14 06:39] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 2: | 行 2: | ||
| # | # | ||
| # ssh远程登录不输入密码 | # ssh远程登录不输入密码 | ||
| - | 执行< | + | 执行<span style=" |
| 进入目录.ssh下,将id_rsa.pub里的内容添加到远程的机子.ssh下的authorized_keys文件中(文件不存在的话就创建一个) | 进入目录.ssh下,将id_rsa.pub里的内容添加到远程的机子.ssh下的authorized_keys文件中(文件不存在的话就创建一个) | ||
| 这样在远程登录的时候就不用输入密码 | 这样在远程登录的时候就不用输入密码 | ||
| - | < | + | |
| + | ``` | ||
| ssh-keygen -t rsa -C " | ssh-keygen -t rsa -C " | ||
| - | </ | + | ``` |
| # | # | ||
| 行 15: | 行 17: | ||
| # | # | ||
| # git init 初始化方法 | # git init 初始化方法 | ||
| - | < | + | |
| + | ``` | ||
| git init (个人使用) | git init (个人使用) | ||
| git --bare init 初始化成裸库 | git --bare init 初始化成裸库 | ||
| git --bare init sample.git | git --bare init sample.git | ||
| - | </ | + | ``` |
| # | # | ||
| # =添加远程库 | # =添加远程库 | ||
| 本地已建有库,把本地库推送到github上(远程库需要建立对应库),本地库和远程库相互关联. | 本地已建有库,把本地库推送到github上(远程库需要建立对应库),本地库和远程库相互关联. | ||
| - | < | + | |
| + | ``` | ||
| git remote add origin git@github.com: | git remote add origin git@github.com: | ||
| git push --set-upstream origin master | git push --set-upstream origin master | ||
| - | </ | + | ``` |
| # | # | ||
| # =克隆远程库 | # =克隆远程库 | ||
| - | < | + | |
| + | ``` | ||
| git clone git@github.com: | git clone git@github.com: | ||
| 行 39: | 行 46: | ||
| centos git clone 报错 fatal: HTTP request failed 解决办法 | centos git clone 报错 fatal: HTTP request failed 解决办法 | ||
| yum update -y nss curl libcurl | yum update -y nss curl libcurl | ||
| - | </ | + | ``` |
| git默认拒绝了push操作,需要进行设置,修改.git/ | git默认拒绝了push操作,需要进行设置,修改.git/ | ||
| - | < | + | |
| + | ``` | ||
| [receive] | [receive] | ||
| | | ||
| - | </ | + | ``` |
| # | # | ||
| 别名alias | 别名alias | ||
| - | < | + | |
| + | ``` | ||
| git config --global alias.st status | git config --global alias.st status | ||
| git config --global alias.co checkout | git config --global alias.co checkout | ||
| 行 55: | 行 66: | ||
| git config --global alias.br branch | git config --global alias.br branch | ||
| git config --global alias.mr merge | git config --global alias.mr merge | ||
| - | </ | + | ``` |
| # | # | ||
| # 基本使用 | # 基本使用 | ||
| - | < | + | |
| + | ``` | ||
| 提交修改到暂存区: | 提交修改到暂存区: | ||
| 从暂存区提交版本到库: | 从暂存区提交版本到库: | ||
| 查看状态: | 查看状态: | ||
| - | </ | + | ``` |
| 版本回退 | 版本回退 | ||
| - | < | + | |
| + | ``` | ||
| git reset --hard HEAD^ | git reset --hard HEAD^ | ||
| git reset --hard 版本号 | git reset --hard 版本号 | ||
| 行 73: | 行 88: | ||
| git reset HEAD file | git reset HEAD file | ||
| - | </ | + | ``` |
| HEAD 表示最新版本, | HEAD 表示最新版本, | ||
| HEAD~100表示向上100个版本 | HEAD~100表示向上100个版本 | ||
| - | < | + | |
| + | ``` | ||
| git reflog 会记录版本的每一次变化(提交& | git reflog 会记录版本的每一次变化(提交& | ||
| 行 84: | 行 101: | ||
| git log -1 显示最近1次 log | git log -1 显示最近1次 log | ||
| git log -2 显示最近2次 log | git log -2 显示最近2次 log | ||
| - | </ | + | ``` |
| # | # | ||
| 行 146: | 行 164: | ||
| # git配置文件 | # git配置文件 | ||
| .gitconfig | .gitconfig | ||
| - | < | + | |
| + | ``` | ||
| [push] | [push] | ||
| 行 165: | 行 184: | ||
| [http] | [http] | ||
| postBuffer = 10737418240 | postBuffer = 10737418240 | ||
| + | ``` | ||
| - | </ | ||
linux/git.1791900372.txt.gz · 最后更改: 由 127.0.0.1
