1、git //linux上检测是否安装git
2、sudo apt-get install git //linux上安装git
3、git config --global user.name "Your Name" //设置用户名
git config --global user.email "email@example.com" //设置邮箱信息
4、git init //进入git仓库目录执行此指令,用于初始化git仓库,执行后会新增.git隐藏文件(ls -ah可查看)
5、git add file_name //把文件添加到仓库
6、git commit -m "备注信息" //把暂存区的内容提交到当前分支
7、git status //查看仓库状态
8、git diff file_name //查看文件改变内容
9、git log //查看git版本记录
10、git reset --hard HEAD^ //返回git上一个版本(git reset --hard HEAD~n,返回git当前之前的第n个版本),此时用git log不会看到当前版本信息
git reset --hard 版本号前6位 //用此指令可重回到当前版本(命令行未关闭,找到版本号即可)
11、git reflog //可查看所有git版本信息
12、cat file_name //查看文件内容
13、git rm file_name git commit -m "说明" //删除文件
14、git check -- file_name //commit前恢复的该文件的上一个状态
15、git push //将文件提交到远程仓库
16、git clone https://github.com/shaoyesun/test1.git //克隆远程仓库到本地
17、git checkout -b branch_name //git创建分支并切换HEAD指向新分支
相当于git branch branch_name和git checkout branch_name两条指令
18、git branch // 查看当前分支,当前分支前有*
19、git chechout branch_name //切换分支
20、git merge branch_name //合并分支内容到当前分支
21、git branch -d branch_name //删除分支
22、git stash //可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作
23、git remote //查看远程仓库信息
git remote -v //查看远程仓库详细信息
24、git push origin branch_name //提交分支到远程仓库
25、git tag tag_name //打标签
26、git tag //查看所有标签
27、git tag -d tag_name //删除标签
28、git push origin tag_name/--tags //提交标签到远程仓库