git(五)-checkout进阶与stash
来源:互联网 发布:mac如何解密外置硬盘 编辑:程序博客网 时间:2024/06/07 20:48
git checkout – test.txt原理:
作用:丢弃掉相对于暂存区最后一个添加的文件内容所做的变更。
实际操作:
范围:针对于工作区
git reset HEAD test.txt作用:
将之前添加到暂存区(stage index)的内容从暂存区移除到工作区。
实际操作:
$ git statusOn branch masterChanges to be committed: (use "git reset HEAD <file>..." to unstage) modified: test.txtAdministrator@CeaserWang MINGW64 /e/Study/mygit (master)$ git reset HEAD test.txtUnstaged changes after reset:M test.txtAdministrator@CeaserWang MINGW64 /e/Study/mygit (master)$ git statusOn branch masterChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: test.txtno changes added to commit (use "git add" and/or "git commit -a")
git checkout 2424324 作用:
重点内容
上面我们生成一个游离分支,接下来做一下修改在其上。
整个过程:
分支改名:
git branch -m master master2
stash命令:
• 保存现场
• git stash
• git stash save ‘name XXX ’
• git stash list
• 恢复现场
• git stash apply(stash内容并不不删除,需要通过git stash drop
stash@{0}⼿手动删除)
• git stash pop(恢复的同时也将stash内容删除)
• git stash apply stash@{0}
git stash drop stash@{0} 删除保存的记录
实际操作:
我们在master分支创建新的分支dev,然后在master分支修改文件并且进行一次提交,接着切换到dev分支,在dev分支修改也进行一次提交,此时如果再次执行切换到master分支会出错:
$ git checkout mastererror: Your local changes to the following files would be overwritten by checkout: test.txtPlease commit your changes or stash them before you switch branches.Aborting
这在我们的日常开发中非常常见,从主干拉了2个分支A和B,开发者者在A分支开发了一半,但是紧接着要转到B分支进行开发,但是A分支的代码是不能提交的,因为没有开发完毕,才是就需要暂存A分支的内容,下次回到A的时候从暂存中恢复出来。
- git(五)-checkout进阶与stash
- git stash pop 与 git stash apply git stash apply && git stash drop.
- git checkout与git reset
- git stash
- git stash
- git stash
- git stash
- git stash
- git stash
- Git Stash
- git stash
- git stash
- git stash
- git stash
- git stash
- git-stash
- git stash
- git stash
- 【iOS】TestFlight 发布包测试
- 关于fork一些有意思的问题
- 【其他】神舟精盾K470-i3 D3更换支持5GHz的双频无线网卡
- c#中选择排序和冒泡排序比较
- 过河 FZU
- git(五)-checkout进阶与stash
- UiAutomator2—By、BySelector
- android 6.0录制动态适配
- Unity《干货收集(持续收集中)》
- rgb-d slam 问题解决:create’ is not a member of ‘cv::FeatureDetector {aka cv::Feature2D}’ detecto
- 匿名函数lambda
- 【JAVA EE】体系总结
- CodeForces296C【线段树】
- PHP SOCKET编程(必看)