//切换分支
git checkout 分支名

 

//创建本地分支
git checkout -b 分支名

 

//提交分支到远程
git push

 

//强制提交分支到远程
git push -f

 

//查看所有分支
git branch -a

 

//删除分支
git branch -d 分支名

 

//撤回修改
git checkout 文件路径

 

//撤回所有修改
git checkout .

 

//把A分支合并到B
1、git checkout B //切换到B分支
2、git rebase A //合并A到B
3、git push -f //提交到远程

 

//获取最新提交
git pull 或 git pull -r

 

//提交本地代码
1、git add .
2、git commit -m'注释'

 

//合并多个提交为一个
git rebase -i head~2

 

//把A分支合并到B
1、git checkout B //切换到B分支
2、git rebase A //合并A到B
如果有冲突,先解决冲突
git rebase --continue 继续
git rebase --abort 撤销合并
3、git push -f //提交到远程

 

//打标签

1、git tag -a {标签版本号} -m '{注释}'  //创建标签

2、git push --tags  //提交标签到远程

 

//配置用户信息

1、git config --global user.email "{你的邮箱}"
2、git config --global user.name "{你的昵称}"

 

//更新gitignore文件

1、git rm -r --cached .  //删除原有缓存

2、编辑gitignore文件

3、git add . 

4、git commit -m'{备注}'  //提交更改到本地

5、git push -f  //提交到远程

 

//删除某次commit内容

方法一:

  1、git log  //拿到commit id,如:

    

  2、git reset --hard {commit id}^  //撤销commit命令

  3、git push -f

方法二:

  1、git rebase -i head~{提交的数量}  //提交的数量要按提交时间倒序之后包含你要删除的提交的次数,如:

    

  2、要删除的commit前面的pick改为drop,如:

    

  3、:q或:wq  //退出编辑页面

  4、git push -f

 

如有疑问可咨询: