git:多个commit合并提交

git:多个commit合并提交


学习ror和git有段时间了,但在git comit提交的时候因为需要重新修改code的小bug和小错误,而重复的提交在写commit_message的时候就会很尴尬,总结方法如下:


  •   如果在提交前已经进行了错误的commit合并的话执行 git reset (注意:这样会丢失没有提交的修改,并且不会留下任何痕迹)http://blog.sina.com.cn/s/blog_68af3f090100rp5r.html
    1. #回退所有内容到上一个版本  

     

  • git reset HEAD^  

 

#回退a.py这个文件的版本到上一个版本  

 

git reset HEAD^ a.py    

 

#向前回退到第3个版本  

 

git reset –soft HEAD~3  

 

#将本地的状态回退到和远程的一样  

 

git reset –hard origin/master  

 

#回退到某个版本  

 

git reset 057d  

 

#回退到上一次提交的状态,按照某一次的commit完全反向的进行一次commit  

 

git revert HEAD  

使用 git rebase --abort  用来restore原来的<branch> 并且删除 .git / rebase-apply 文件 随后可以使用git log的命令查看自己的commit历史看是否已经恢复到你期望的状态 使用git rebase -i HEAD~*  其中* 代表你期望合并的commit的数目,会出现*数目的commit的历史上面的是*条历史中最晚的,即使*条数目多了也没事,只需要在你期望提交的commit下面的commit前面的pick更改成S就行,在终端中修改使用到了nano编辑器,CTRL_O和CTRL_X保存退出 然后push到github上( 适用 git push -f origin master 需要谨慎 )

Ubuntu_NANO编辑器操作:
^表示键盘上的ctrl键,^G表示同时按下ctrl和g 
(F1)表示按F1键 ,M-表示使用alt+后面的键 

^G ==(F1) Invoke the help menu 
调用帮助菜单 

^X ==(F2) Close currently loaded file/Exit from nano 
退出 

^O ==(F3) Write the current file to disk == ^O WriteOut 
保存 
然后回车就保存了 

^J ==(F4) Justify the current paragraph 
调整当前段落(注意:编辑配置文件的不要用这东西,格式一下就出问题了哦) 

^R ==(F5) Insert another file into the current one 
插入其他的文件到当前的文件,而且查找文件的时候支持tab 

^W ==(F6) Search for text within the editor 
查找 

^Y ==(F7) Move to the previous screen 
上一屏幕 

^V == ( F8 ) Move to the next screen 
下一屏幕 

^K ==(F9) Cut the current line and store it in the cutbuffer 
裁减当前一排并保存在缓冲区 

^U ==(F10) Uncut from the cutbuffer into the current line 
将缓冲区的东西粘贴到此 

^C ==(F11) Show the position of the cursor 
显示光标位置 

^T ==(F12) Invoke the spell checker, if available 
调用拼写检查程序 

^P Move up one line 
向上移动一行 

^N Move down one line 
向下移动一行 

^F Move forward one character 
向前移动光标一格 

^B Move back one character 
向后移动光标一格 

^A Move to the beginning of the current line 
移动到当前行的开头 

^E Move to the end of the current line 
移动到当前行的末尾 

^L Refresh (redraw) the current screen 
刷新当前屏幕 

^^ (M-A) Mark text at the current cursor location 
标记文本 

^D Delete the character under the cursor 
删除光标后一个字母 

^H Delete the character to the left of the cursor 
向左边删一个字母 

^I Insert a tab character 
插入一个tab值 

^\ (F14) (M-R) Replace text within the editor 
查找并且替换 

^M Insert a carriage return at the cursor position 
插入一个回车 

^_ (F13) (M-G) Go to a specific line number 
跳转到某行 

^Space Move forward one word 
前进一个单词 

M-Space Move backward one word 
后退一个单词 

M-] Find other bracket 
搜索下一个括号 

M-< Open previously loaded file 
打开先前加载的文件 

M-> Open next loaded file 
打开下一个加载的文件 

M-I Auto indent enable/disable 
是否首行缩进 

M-Z Suspend enable/disable 
是否悬挂 

M-X Help mode enable/disable 
帮助模式 

M-M Mouse support enable/disable 
鼠标支持 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值