http://blog.youkuaiyun.com/tomatozaitian/article/details/73515849
输入自己的相关信息
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
ssh-keygen -t rsa -C "you@example.com"
1.从远程库克隆到本地:git clone 网站上的仓库地址
git clone https://github.com/Netflix/dial-reference.git
2.git log 查看 提交历史
git log --oneline
以一行来显示修改的备注
git log -2
显示最近的两次修改
3.查看提交的内容差异
git log -1 -p
-1最近的1一次
4.查看当前目录下相对于服务器有哪些修改状态
git status
5.查看当前文件的修改
git diff README.md
6.增加文件到暂存区
git add xxx
删除暂存区
git rm xxx
7.提交到库
git commit -m '描述' ./xxx
8.撤销工作区的修改
git checkout README.md
9.
先有本地库,后有远程库,将本地库push到远程库
mkdir test
cd test
git init
touch test.c
关联本地仓库和GitHub库:
origin远程库的名字
git remote add origin 网站上的仓库地址
第一次将本地仓库推送到GitHub上:
推送到远程库origin的master分支上
git push -u origin master
10.更新到最新
git pull
git push <远程主机名> <本地分支名>:<远程分支名>
git push origin master:master
git pull <远程分支>:<本地分支>
11.查看某一个版本的修改
git log -5 --oneline
git show 92656xxxx
12查看两个版本间修改过哪些文件(不是具体文件内的内容)
git log --oneline
git diff header1 header2 --name-only
git diff header1 --name-only
区别于
git show header2
13 回退到指定commit的版本,工作区与暂存区均变化(在未push前,但是commit后,想撤销某个commit的本地修改时,采用回退到需要撤销版本的上一个版本)
git reset --hard commit_id
git reset --soft commit-id或git reset commit_id
撤销commit记录(版本库),但是工作区和暂存区的修改保留
完成Commit命令的撤销,但是不对代码修改进行撤销,可以直接通过git commit 重新提交对本地代码的修改
撤销push到服务器的提交
git reset --hard xxx
git push origin HEAD --force
https://blog.youkuaiyun.com/hanchao5272/article/details/79435730
14.查看所有分支
git branch -a
15.查看当前使用分支(结果列表中前面标*号的表示当前使用分支)
git branch
16.切换分支
git checkout 分支名
配置一个公钥,所有需要的电脑 都能用
更改id_rsa和id_rsa.pub的权限,保持两边的电脑的权限一致
https://www.cnblogs.com/guochaoxxl/p/6823104.html
git解决冲突
https://blog.youkuaiyun.com/qq_29060365/article/details/80290844
git 历史提交记录log(git GUI)图文详解
https://blog.youkuaiyun.com/tantexian/article/details/42641457?utm_source=blogxgwz1
介绍
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000