IntelliJ支持git stashes以及它自己的内置shelve命令.这些似乎在目的和效用上几乎相同.他们之间有什么区别?
我有一个很大的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) 如何撤消特定文件夹中的更改?
我修改了多个文件夹中的文件
app/code/core/
app/code/local/
app/design/frontend/
Run Code Online (Sandbox Code Playgroud)
我想撤消在文件中所做的所有更改app/code/core/,同时保持在app/code/local/和中存在的文件中修改的更改app/design/frontend/.
Git Extensions有没有办法只隐藏一些未提交的文件?
假设我在工作目录中更改了三个文件(未提交),但我只想隐藏其中的两个.仅供参考未提交的文件是否已暂存似乎并不重要 - 当我使用存储时,它们都被隐藏起来.
我需要存储一组包含新文件的更改 - 不删除被忽略的目录.
所以我尝试了这个:
git add --intent-to-add myNewFile.txt
git stash
Run Code Online (Sandbox Code Playgroud)
结果是:
error: Entry 'myNewFile.txt' not uptodate. Cannot merge.
Cannot save the current worktree state
Run Code Online (Sandbox Code Playgroud)
如何隐藏已修改的文件以及一个或多个选定的新文件,但不影响任何其他文件或目录(特别是那些文件或目录.gitignore)?
(这不是我如何git存储特定文件的重复?因为这个问题是如何存储以前添加过的文件.我的问题是存储一个尚未添加的文件.)
我尝试从一个本地分支转到另一个分支.Git告诉我,我不能这样做,因为我的local changes to the following files would be overwritten by checkout.
然后我得到一个"推荐" Please, commit your changes or stash them before you can switch branches.
我知道我不需要对上述文件进行更改.可以覆盖它们.所以,我试着stash.我执行git stash file_name.结果我得到:
Usage: git stash list [<options>]
or: git stash show [<stash>]
or: git stash drop [-q|--quiet] [<stash>]
or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
or: git stash branch <branchname> [<stash>]
or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
[-u|--include-untracked] [-a|--all] [<message>]]
or: git stash …Run Code Online (Sandbox Code Playgroud) 我有一些如下所示的已编辑文件,并且还有一些新创建的文件
现在,我想存放未跟踪的文件(在本例中为db/migrate/20161212071336_add_paranoid_fields.rb,但不存放更改的文件)。
我应该怎么做?
首先,我创建了这个文件,然后我意识到我并不需要它(需要删除它才能使我的程序正常工作)。但将来可能会需要。
stash -p,但这只会隐藏跟踪的文件。我有很多已更改的文件,并且只想存储一些已修改的文件。
例如,我的存储库如下所示:
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: main.cpp
modified: MyClass.h
modified: MyClass.cpp
Run Code Online (Sandbox Code Playgroud)
我想藏匿MyClass.h和MyClass.cpp唯一的。
我发现了这个问题,但接受的答案似乎是错误的,投票最多的答案要求交互式添加每个大块/文件。
有没有一种简单的方法来存储一组特定的文件?最好在单个命令中,而不必以交互方式一个一个地选择文件或暂存/取消暂存。
我读到这个问题:how can I git stash a certain file?
所以我知道我可以使用git stash push <path>或git stash --patch从控制台,但我想知道 PhpStorm 是否有一个更友好的 UI,用于仅存储我的更改的选定部分(类似于提交时的界面)。
预先非常感谢!
我想存储一些文件,在这些文件中,有些文件我想完全存储,有些文件我想存储其中的一部分。
例如,假设我有以下文件:
前 2 个文件(1 和 2)是新文件,未跟踪。另外 2 个(3 和 4)被跟踪,其中一个(3)有几行我想隐藏,也有几行我不想,而另一个文件(4)我想全部隐藏。
在这种情况下我该如何隐藏?
更新:如果存储特定文件,则可以在git stash push -m _STASH_MESSAGE_ _PATH_1 _PATH_2
我的情况下,我需要存储部分文件更改(例如第 1-20 行已更改,但我只想存储 1-12 行并保留 13-20 行继续工作)