我有一个Git仓库,我已经删除了使用rm(不是 git rm)的四个文件,我的Git状态如下所示:
# deleted: file1.txt
# deleted: file2.txt
# deleted: file3.txt
# deleted: file4.txt
Run Code Online (Sandbox Code Playgroud)
如何从Git中删除这些文件,而无需手动浏览并添加如下所示的每个文件:
git rm file1 file2 file3 file4
Run Code Online (Sandbox Code Playgroud)
理想情况下,我正在寻找能够以同样方式工作的东西git add .,如果可能的话.
我有一个很大的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) 我有一个git repo,我需要在没有冲突的情况下工作.它是.net/c#mvc repo.问题是dll和pdb文件.这些文件意外地被提交到了repo,所以当我做我的初始时git pull,我得到了另一个开发人员提交的所有这些文件.
我设置了.gitignore这样的:
bin/
obj/
App_data/
Run Code Online (Sandbox Code Playgroud)
从其他帖子我相信这是我应该做的全部,但是,如果我构建我的项目并运行git status它会显示许多将要提交的dll和pdb文件.
这是因为当克隆它时,那些文件存在于repo中吗?如果是这样,删除这些文件的最佳方法是什么?
我过去使用git命令为我的github文件:
add --update :/
Run Code Online (Sandbox Code Playgroud)
正如有人告诉我这是获取已添加,删除和更新的所有文件的最佳方式.
但是阅读之后:"git add -A"和"git add"之间的区别.
我想也许我应该用 git add -A
有人能告诉我是否存在差异以及git add --update :/实际上有什么作用?
当我们合并时,我们保留 Maven pom.xml 文件的本地版本:
git merge origin/remote_branch
git checkout --ours **/pom.xml pom.xml
git add **/pom.xml pom.xml
git commit -m "Merge"
Run Code Online (Sandbox Code Playgroud)
除非本地分支中的 pom.xml 文件已被删除,否则这非常有效。运行上面的命令 #2 后,我们得到一个错误:
d:\code>git checkout --ours **/pom.xml pom.xml
error: path 'blah/pom.xml' does not have our version
Run Code Online (Sandbox Code Playgroud)
...并且在此错误之后,下一个命令 #3git add **/pom.xml pom.xml有效地添加了远程 pom.xml 文件 - 这正是我们不想要的。
我们如何更新脚本来处理这个问题?
git ×5
.net ×1
git-add ×1
git-checkout ×1
git-commit ×1
git-rm ×1
git-stash ×1
github ×1
merge ×1