-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_command.txt
52 lines (50 loc) · 2.26 KB
/
git_command.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
git clone [url] //从github下载库
git config --global uers.name //设置贡献者名字
git config --global uers.email //设置贡献者邮箱
git config --list //查看所有配置项
git status //查看状态
git add name或者. //将工作区的内容添加到暂存区 name为单个输入 .为所有更改文件跟新
git commit //将暂存区内容添加到 版本库 -m 快速添加注释 -a -m 跳过git add 直接将工作区内容添加到版本库 并添加注释
git diff //对比命令 默认对比工作区和暂存区
git diff --cached(--staged) //对比暂存区和版本库
git diff name //对比工作区和版本库 name为版本库的名字
git reset HEAD name //撤销 让已经add到暂存区的文件 回到工作区 name 文件名
git checkout -- name //撤销 让工作区 返回到版本库的状态 name 文件名
git commit -m --amend //撤销 上一次的提交 把暂存区的内容和上一次提交内容 一起重新提交
git rm name //工作区文件删除时,清除暂存区的文件
git rm -f name //清除暂存区和工作区的文件
git rem --cached name //清除暂存区的文件
git checkout commit_id name //恢复文件 commit码为版本库修改吗 可以不写全 name 文件名
git reset --hard commit_id //恢复版本 commit码为版本库修改吗 可以不写全
git reset --hard HEAD^ //返回上一个版本
git reset --hard HEAD~3 //返回以前版本 ~数字为返回第几个版本
git reflog //前几步操作 状态码
---------------------同步远程-----------------------
git remote //查看项目名
git push name1 name2 //同步到远程服务器 name1 本地项目名称 name2 同步分支名字
git pull //更新文件自动合并
git fetch //下载远端文件
git merge origin/master //手动合并
---------------------开源项目协作--------------------
fork 复制库为自己的库
pull request 请求修改
---------------------分支功能------------------------
git branch //查看分支
git branch name //创建分支name
git checkout name //切换分支
git checkout -b name //创建分支name并切换到该分支
git branch --merged //查询和当前分支合并的分支有哪些
git branch --no-merged //查询没和当前分支合并的分支有哪些
git barnch -d name //删除name分支(一般情况只允许删除已经合并的分支)
git barnch -D name //强制删除name分支(可以删除没有合并的分支)
git tag //查看标签
git tag value //设置标签value
ssh-keygen -t rsa -C "[email protected]"
git config --global user.name 'onovps'
git config --global user.email '[email protected]' #全局联系方式,可选
git init
git add .
git commit -m "测试"
git remote add origin https://[email protected]/fancey/test
git pull origin master
git push -u origin master