linux:git
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| linux:git [2025/08/01 09:01] – [git init 初始化方法] user01 | linux:git [2026/10/14 06:39] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| GIT 是一个分布式的版本管理工具 | GIT 是一个分布式的版本管理工具 | ||
| - | ================= | + | # |
| - | ====== | + | # 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 " | ||
| - | </ | + | ``` |
| - | ================= | + | |
| + | # | ||
| 安装git,用它的图形界面gitk,需要tcl, | 安装git,用它的图形界面gitk,需要tcl, | ||
| - | ================= | + | # |
| - | ======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: | ||
| 行 40: | 行 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 | ||
| 行 56: | 行 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 版本号 | ||
| 行 74: | 行 88: | ||
| git reset HEAD file | git reset HEAD file | ||
| - | </ | + | ``` |
| HEAD 表示最新版本, | HEAD 表示最新版本, | ||
| HEAD~100表示向上100个版本 | HEAD~100表示向上100个版本 | ||
| - | < | + | |
| + | ``` | ||
| git reflog 会记录版本的每一次变化(提交& | git reflog 会记录版本的每一次变化(提交& | ||
| 行 85: | 行 101: | ||
| git log -1 显示最近1次 log | git log -1 显示最近1次 log | ||
| git log -2 显示最近2次 log | git log -2 显示最近2次 log | ||
| - | </ | + | ``` |
| - | ================= | + | # |
| Git鼓励大量使用分支: | Git鼓励大量使用分支: | ||
| 查看分支:git branch | 查看分支:git branch | ||
| 行 108: | 行 125: | ||
| git stash pop 恢复刚才保存起来的现场 | git stash pop 恢复刚才保存起来的现场 | ||
| - | ================= | + | # |
| git 全局忽略.svn目录 | git 全局忽略.svn目录 | ||
| 行 116: | 行 133: | ||
| 执行命令 | 执行命令 | ||
| - | ================= | + | # |
| - | =======搭建Git服务器======= | + | # =搭建Git服务器 |
| 准备一台运行Linux的机器 | 准备一台运行Linux的机器 | ||
| 行 146: | 行 162: | ||
| - | ====== | + | # git配置文件 |
| .gitconfig | .gitconfig | ||
| - | < | + | |
| + | ``` | ||
| [push] | [push] | ||
| 行 167: | 行 184: | ||
| [http] | [http] | ||
| postBuffer = 10737418240 | postBuffer = 10737418240 | ||
| + | ``` | ||
| - | </ | ||
linux/git.1754010083.txt.gz · 最后更改: (外部编辑)
