git 常用操作

来源:互联网 发布:python ctypes 编辑:程序博客网 时间:2024/06/10 12:16

整理一下自己使用git时候的操作

提交

git cherry-pick

从其他分支获取某次的提交

查看

git log –author=XXXX

查看作者为某人的更改

git show

某次提交的修改内容

it reflog

命令查看你的历史变更记录

回退

git reset –hard HEAD@{n}

回退到某个引用位置

git reset –hard origin/master

放弃本地修改,强制与远程分支保持一致

git revert

撤销某次commit,这次revert操作也当做一次commit被保存

git revert -m

撤销某次merge,branch-id是本次merge 的两个分支的序号,如果把test2合并到test1里,那么test1为1,test2为2,想要把分支撤销会merge前的test1,那么序号写1

异常处理

git bash崩溃后的问题

Git操作的过程中突然显示Another git process semms to be running in this repository, e.g. an editor opened by ‘git commit’. Please make sure all processes are terminated then try again. If it still fails, a git process remove the file manually to continue…
git被另外一个程序占用,重启机器也不能够解决。原因在于Git在使用过程中遭遇了奔溃,部分被上锁资源没有被释放导致的。

解决方案:进入项目文件夹下的 .git文件中(需要显示隐藏文件夹)删除index.lock文件即可。

原创粉丝点击