可能重复:
如何仅存储已更改的多个文件中的一个文件
如何保存特定文件,将当前已修改的其他文件保存在我要保存的存储区中?
例如,如果git status给我这个:
younker % gst
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes 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: app/controllers/cart_controller.php
# modified: app/views/cart/welcome.thtml
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
我只想藏匿app/views/cart/welcome.thtml,我该怎么做?有点像(但当然这不起作用):
git stash save welcome_cart app/views/cart/welcome.thtml
Run Code Online (Sandbox Code Playgroud) 我目前在工作目录中有三个已修改的文件.但是我希望其中一个重置为HEAD状态.
在SVN我会使用svn revert <filename>(svn update <filename>如果需要的话后跟),但在git我应该使用git reset --hard.但是,此命令无法在单个文件上运行.
有没有办法在git中丢弃单个文件更改并用新的HEAD副本覆盖它?
我shelve对Git 的方面非常不熟悉.如果stash用来放弃未完成的工作shelve那么呢?你会用它做什么用的?
是否有可能让git在特定文件之间产生差异,因为它现在存在,并且在最后一次提交之前存在改变它?
也就是说,如果我们知道:
$ git log --oneline myfile
123abc Fix some stuff
456def Frobble the foos
789dba Initial commit
Run Code Online (Sandbox Code Playgroud)
然后git diff 456def myfile显示myfile的最后一次更改.没有所产生的知识,是否有可能做同样的事情git log; 123abc有什么变化?
我希望能够从单个文件中隐藏更改:
git stash save -- just_my_file.txt
Run Code Online (Sandbox Code Playgroud)
以上不起作用.任何替代品?
我刚刚使用"git add -p"为索引添加了一堆更改,我才意识到我错过了一个应该进入上一次提交的更改.
我现在不能提交--amend因为我已经将所有这些新的更改添加到索引中,并且我不想使用'git reset'将它们全部从索引中删除,因为它需要很长时间才能添加它们又回来了.
我需要的是像'git stash'这样只会隐藏索引的东西 - 它应该只保留工作文件.然后我可以存储索引,添加缺少的更改,提交它,然后弹出存储并使我的索引恢复原样.
它看起来不像'git stash'能够做到这一点,但我错过了什么吗?谢谢!
我有一个很大的git项目,我愚蠢地导入到eclipse并运行autoformat.现在,项目中的每个文件都显示为已修改.而不是提交我的格式化文件,我宁愿还原我只格式化的所有文件,而不是其他更改.例如:
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
# modified: dir/file1.cpp
# modified: dir/file1.h
# modified: dir/file2.cpp
# modified: dir/file2.h
# modified: dir/file3.cpp
# modified: dir/file3.h
# modified: dir/file4.cpp
# modified: dir/file4.h
Run Code Online (Sandbox Code Playgroud)
我知道file2.cpp,file2.h和file3.cpp已与内容修改(即,不只是格式化).我想隐藏对这三个文件的更改,然后签出一个旧版本,以便我可以在以后重新应用这些文件的更改.我宁愿避免这样的事情:
$ …Run Code Online (Sandbox Code Playgroud) 我试图找出如何在许多未提交的更改中存储两个特定文件.
这个非常有前途的答案,Stash只有一个文件中的多个文件已经改变了Git?,没有显示用法,我遇到了麻烦.
以下不起作用,手册页不是很有帮助(它似乎谈论终端输出,而不是实际存储).我想隐藏application.conf,plugins.sbt然后提交其他所有内容.
app (master)$ git status
On branch master
Your branch is ahead of 'origin/master' by 29 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: views/mobile/blog.scala.html
modified: views/mobile/slideshow.scala.html
modified: ../public/css/mobile/styles.css
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: ../conf/application.conf
Changes not staged for commit:
(use "git add <file>..." to update …Run Code Online (Sandbox Code Playgroud) 这个问题的简短版本是:如何在git不触发自动合并的情况下弹出存储?
现在为更长的版本......
考虑以下玩具示例替代git stash ... + git pull ... + git pop.
首先,git status显示工作目录中的唯一修改是某个跟踪文件foo.
# On branch master
# Changes 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: foo
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
现在,为了工作目录重置为干净的状态,作为一个先决条件的运行git pull,我暂时命名修改后的文件foo(一些未经跟踪的名称),并恢复的版本foo中 …