git学习笔记
Sammary
学习git的使用
先上链接:
git简明上手教程:git 简明指南 (runoob.com)
git全指令手册:Git - Reference (git-scm.com)
创建远程仓库
- 导航到目的文件夹下,then执行
1 | git init |
正常会出现Initialized empty Git repository in …….
- 向仓库添加文件后并提交到本地,执行
1 | git add . |
在本地仓库添加一个远程仓库,并把本地仓库master分支跟踪到远程分支
先上gitee或者github等去新建一个仓库,远程仓库地址使用http://git.XXXX.com/XXX/XXX.git/也可以
1 | git remote add origin git@github.com:saber1360/JudgeSystem.git |
查看远程仓库地址
1 | git remote -v |
修改远程仓库地址
1 | git remote set-url origin http://git.XXXX.com/XXX/XXX.git/ |
基本使用
- 添加文件
1 | git add . |
- 提交到本地仓库
1 | git commit -m "注释" |
上传到远程仓库
git push <远程主机名> <远程分支名>:<本地分支名>
1 | # 将本地master分支上传到远程 |
- 分支管理
- 列出分支
1 | git branch |
- 创建分支
1 | git branch (branchname) |
- 切换分支
1 | git checkout (branchname) |
- 合并分支
1 | # 将branchname合并到当前所在分支 |
- 删除分支
1 | git branch -d (branchname) |
- 回溯
查看提交记录
1 | # 加上--oneline,查看简洁版本的记录 |
得到对应版本号后
1 | git reset --hard 版本号 |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 焚琴煮鹤のBlog!
评论