如何使用git merge --squash?

时间:2011-03-15 07:47:45

标签: git git-merge git-squash

我有一个远程Git服务器,这是我想要执行的场景:

  • 对于每个错误/功能,我创建了一个不同的Git分支

  • 我继续使用非官方的Git消息在Git分支中提交我的代码

  • 在顶级存储库中,我们必须使用官方Git消息对一个错误进行一次提交

那么如何将我的分支合并到远程分支,以便他们只为我的所有签到提交一个提交(我甚至想为此提供提交消息)?

15 个答案:

答案 0 :(得分:1607)

假设您的错误修复分支名为bugfix,并且您希望将其合并到master中:

git checkout master
git merge --squash bugfix
git commit

这将从bugfix分支进行所有提交,将它们压缩为1次提交,并将其与您的master分支合并。


<强>解释

git checkout master

切换到master分支。

git merge --squash bugfix

bugfix分支获取所有提交,并将其与当前分支合并。

git commit

从合并的更改中创建一个提交。

省略-m参数允许您在完成提交之前修改包含来自压缩提交的每条消息的草稿提交消息。

答案 1 :(得分:99)

最终为我解决的是comment显示:

git checkout main
git merge --squash feature

相当于:

git checkout feature
git diff main > feature.patch
git checkout main
patch -p1 < feature.patch
git add .

当我想将一个功能分支与105(!!)提交合并并将它们全部压缩成一个时,我不想git rebase -i origin/master因为我需要单独解决每个的合并冲突中间提交(或至少是git无法弄明白的提交)。使用git merge --squash获取我想要的结果,用于合并整个功能分支的单个提交。而且,我最多只需要进行一次手动冲突解决。

答案 2 :(得分:93)

您想要与壁球选项合并。如果你想一次做一个分支就行了。

git merge --squash feature1

如果你想在单次提交的同时合并所有分支,那么首先以交互方式进行rebase并压缩每个特征,然后进行章鱼合并:

git checkout feature1
git rebase -i master

压入一个提交,然后重复其他功能。

git checkout master
git merge feature1 feature2 feature3 ...

最后一次合并是“章鱼合并”,因为它正在同时合并很多分支。

希望这有帮助

答案 3 :(得分:21)

如果git merge bugfix上已经main,您可以将合并提交压缩为:{/ p>

git reset --soft HEAD^1
git commit

答案 4 :(得分:8)

使用自定义提交将newFeature分支合并到master

git merge --squash newFeature && git commit -m 'Your custom commit message';

相反,如果你做了

git merge --squash newFeature && git commit

您将收到一条提交消息,其中包含您可以自定义的所有newFeature分支提交。

答案 5 :(得分:3)

我知道这个问题不是专门针对Github的,但是由于Github的使用如此广泛,这是我一直在寻找的答案,因此我将在这里分享。

Github可以执行南瓜合并,具体取决于为存储库启用的合并选项。

如果启用了南瓜合并,则“压缩并合并”选项应出现在“合并”按钮下方的下拉菜单中。

Screenshot of "Squash and merge" Github feature

答案 6 :(得分:2)

假设您在功能/任务1中进行了多次提交。

  1. 转到您的项目分支(project / my_project)

    parentSprite.physicsBody?.categoryBitMask = 0
    parentSprite.physicsBody?.collisionBitMask = 0
    
    physicsSprite.physicsBody?.collisionBitMask = 1
    physicsSprite.physicsBody?.categoryBitMask = 1
    
  2. 创建一个新分支(功能/ task1_bugfix)

    git checkout project/my_project
    
  3. 使用git checkout -b feature/task1_bugfix 选项进行标记

    --squash
  4. 创建单个提交

    git merge --squash feature/task1
    
  5. 推送分支

    git commit -am "add single comments"
    

答案 7 :(得分:0)

对于Git

创建新功能

通过终端/壳牌:

puts(the_string)

这不提交它,允许你先审查它。

然后提交,并完成这个新分支的功能,并删除/忽略旧分支(你开发的那个)。

答案 8 :(得分:0)

如果出现错误:由于文件未合并,无法进行提交。

git checkout master
git merge --squash bugfix
git add .
git commit -m "Message"

修复了所有冲突文件

git add . 

您也可以使用

git add [filename]

答案 9 :(得分:0)

在压入您的本地分支之前先压它:

  1. 检出相关分支以进行处理(如果尚未检出)。

  2. 找到您希望保留的最早提交的密码。

  3. 从该提交创建/签出新分支(tmp1)。

    git checkout -b tmp1 <sha1-of-commit>

  4. 将原始分支合并为新的一个。

    git merge --squash <original branch>

  5. 使用汇总提交消息提交由合并创建的更改。

    git commit -m <msg>

  6. 签出您要压榨的原始分支。

    git checkout <branch>

  7. 重置为您希望保留的原始提交。

    git reset --soft <sha1>

  8. 根据新的tmp1分支对该分支重新设置基础。

    git rebase tmp1

  9. 就是这样-现在,在确定一切正常后,立即删除临时tmp1分支。

答案 10 :(得分:0)

git checkout YOUR_RELEASE_BRANCH
git pull
git checkout -b A_NEW_BRANCH
git merge --squash YOUR_BRANCH_WITH_MULTIPLE_COMMITS
git commit -am "squashing all commits into one"
git push --set-upstream origin A_NEW_BRANCH

答案 11 :(得分:0)

您的功能分支已完成,可以仅通过一次提交就提交到母版,开发版或其他目标分支上

  • 转到合并分支:git checkout master && git pull
  • 从干净的本地主服务器创建一个工作分支:git checkout -b work
  • 在工作中合并压缩您的功能分支:git merge --squash your_feature_branch。
  • 使用默认或新消息提交:git commit(带有特定或默认消息)
  • 回到功能分支:git checkout your_feature_branch
  • 将功能分支指向工作目录:git reset --hard work
  • 验证,但您准备推送:git push -f
  • 然后根据需要清理工作分支

将master替换为目标分支:开发等

  • 无需指定从您的母版到功能分支的提交次数。 Git会照顾*

答案 12 :(得分:0)

假设您进行多次提交的分支名称为 bugfix/123,并且您想压缩这些提交。
首先,从 develop 创建一个新分支(或者无论你的仓库名称是什么)。假设新分支的名称为 bugfix/123_up。在 git bash 中签出这个分支 -

  • git 获取
  • git checkout bugfix/123_up
  • git merge bugfix/123 --squash
  • git commit -m "你的消息"
  • git push origin bugfix/123_up

现在这个分支将只有一个包含所有更改的提交。

答案 13 :(得分:-1)

您可以使用我创建的工具来简化此过程:git-squash。例如,要压缩已从master分支分支的feature分支上的所有提交,请输入:

#sha256=a37ee82f1b8ed4b4645619c504311e71ce845b78f40055e78d71add5fab7da82 (from https://pypi.org/simple/opencv-python/)
  Skipping link: none of the wheel's tags match: cp36-cp36m-manylinux1_x86_64: https://files.pythonhosted.org/packages/72/c2/e9cf54ae5b1102020ef895866a67cb2e1aef72f16dd1fde5b5fb1495ad9c/opencv_python-4.2.0.34-cp36-cp36m-manylinux1_x86_64.whl#sha256=dcb8da8c5ebaa6360c8555547a4c7beb6cd983dd95ba895bb78b86cc8cf3de2b (from https://pypi.org/simple/opencv-python/)
  ... lots more link skipping
  Skipping link: none of the wheel's tags match: cp38-cp38-win32: https://files.pythonhosted.org/packages/e6/d6/516883f8d2f255c41d8c560ef70c91085f2ceac7b70b7afe41432bd8adbb/opencv_python-4.2.0.34-cp38-cp38-win32.whl#sha256=1ab92d807427641ec45d28d5907426aa06b4ffd19c5b794729c74d91cd95090e (from https://pypi.org/simple/opencv-python/)
  Skipping link: none of the wheel's tags match: cp38-cp38-win_amd64: https://files.pythonhosted.org/packages/df/9e/56d8b98652ecac8c8f9e59b7f00d5d99a9fa86661adcf324b8dc73351a6b/opencv_python-4.2.0.34-cp38-cp38-win_amd64.whl#sha256=e2206bb8c17c0f212f1f356d82d72dd090ff4651994034416da9bf0c29732825 (from https://pypi.org/simple/opencv-python/)
Given no hashes to check 18 links for project 'opencv-python': discarding no candidates
Using version 4.2.0.34 (newest of versions: bunch of versions....)
Collecting opencv-python>=3
  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpack-y8apfmt3
  Looking up "https://files.pythonhosted.org/packages/85/17/bad54f67bbe27d88ba520c3f59315e95b4e254cd28767c20accacb0597d8/opencv_python-4.2.0.34-cp37-cp37m-win_amd64.whl" in the cache
  Current age based on date: 1902095
  Ignoring unknown cache-control directive: immutable
  Freshness lifeOneWorlde from max-age: 365000000
  The response is "fresh", returning cached response
  365000000 > 1902095
  Using cached opencv_python-4.2.0.34-cp37-cp37m-win_amd64.whl (33.0 MB)
  Added opencv-python>=3 from https://files.pythonhosted.org/packages/85/17/bad54f67bbe27d88ba520c3f59315e95b4e254cd28767c20accacb0597d8/opencv_python-4.2.0.34-cp37-cp37m-win_amd64.whl#sha256=d8a55585631f9c9eca4b1a996e9732ae023169cf2f46f69e4518d67d96198226 (from mmcv>=0.5.1->mmdet==2.0.0+unknown) to build tracker 'C:\\Users\\OneWorld\\AppData\\Local\\Temp\\pip-req-tracker-6eq3f7le'
  Removed opencv-python>=3 from https://files.pythonhosted.org/packages/85/17/bad54f67bbe27d88ba520c3f59315e95b4e254cd28767c20accacb0597d8/opencv_python-4.2.0.34-cp37-cp37m-win_amd64.whl#sha256=d8a55585631f9c9eca4b1a996e9732ae023169cf2f46f69e4518d67d96198226 (from mmcv>=0.5.1->mmdet==2.0.0+unknown) from build tracker 'C:\\Users\\OneWorld\\AppData\\Local\\Temp\\pip-req-tracker-6eq3f7le'
Requirement already satisfied: future in c:\users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages (from torch>=1.3->mmdet==2.0.0+unknown) (0.18.2)
Building wheels for collected packages: mmcv
  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-wheel-93yp2cnh
  Building wheel for mmcv (setup.py) ...   Destination directory: C:\Users\OneWorld\AppData\Local\Temp\pip-wheel-93yp2cnh
  Running command 'C:\Users\OneWorld\anaconda3\envs\open-mmlab2\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OneWorld\\AppData\\Local\\Temp\\pip-install-voimjxde\\mmcv\\setup.py'"'"'; __file__='"'"'C:\\Users\\OneWorld\\AppData\\Local\\Temp\\pip-install-
amd64-3.7\mmcv\video\optflow_warp
  copying mmcv\video\optflow_warp\flow_warp_module.pyx -> build\lib.win-amd64-3.7\mmcv\video\optflow_warp
....etc.

  running build_ext
  skipping './mmcv/video/optflow_warp\flow_warp_module.cpp' Cython extension (up-to-date)
  building 'mmcv._ext' extension
  creating build\temp.win-amd64-3.7
  creating build\temp.win-amd64-3.7\Release
  creating build\temp.win-amd64-3.7\Release\mmcv
  creating build\temp.win-amd64-3.7\Release\mmcv\video
  creating build\temp.win-amd64-3.7\Release\mmcv\video\optflow_warp
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\numpy\core\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /EHsc /Tp./mmcv/video/optflow_warp/flow_warp.cpp /Fobuild\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp/flow_warp.obj
  flow_warp.cpp
  ./mmcv/video/optflow_warp/flow_warp.cpp(37): warning C4244: '=': conversion from 'double' to 'int', possible loss of data
  ./mmcv/video/optflow_warp/flow_warp.cpp(38): warning C4244: '=': conversion from 'double' to 'int', possible loss of data
  ./mmcv/video/optflow_warp/flow_warp.cpp(59): warning C4244: '=': conversion from 'double' to 'int', possible loss of data
  ./mmcv/video/optflow_warp/flow_warp.cpp(60): warning C4244: '=': conversion from 'double' to 'int', possible loss of data
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\numpy\core\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /EHsc /Tp./mmcv/video/optflow_warp\flow_warp_module.cpp /Fobuild\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp\flow_warp_module.obj
  flow_warp_module.cpp
  c:\users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\OneWorld\anaconda3\envs\open-mmlab2\libs /LIBPATH:C:\Users\OneWorld\anaconda3\envs\open-mmlab2\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\um\x64" /EXPORT:PyInit__ext build\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp/flow_warp.obj build\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp\flow_warp_module.obj /OUT:build\lib.win-amd64-3.7\mmcv\_ext.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp\_ext.cp37-win_amd64.lib
  flow_warp_module.obj : warning LNK4197: export 'PyInit__ext' specified multiple OneWorldes; using first specification
     Creating library build\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp\_ext.cp37-win_amd64.lib and object build\temp.win-amd64-3.7\Release\./mmcv/video/optflow_warp\_ext.cp37-win_amd64.exp
  Generating code
  Finished generating code
  installing to build\bdist.win-amd64\wheel
  running install
  running install_lib
  creating build\bdist.win-amd64
  creating build\bdist.win-amd64\wheel
  creating build\bdist.win-amd64\wheel\mmcv
  creating build\bdist.win-amd64\wheel\mmcv\arraymisc
  copying build\lib.win-amd64-3.7\mmcv\arraymisc\quantization.py -> build\bdist.win-amd64\wheel\.\mmcv\arraymisc
...
... bunch of copying and creating...
...
  running install_egg_info
  Copying mmcv.egg-info to build\bdist.win-amd64\wheel\.\mmcv-0.5.8-py3.7.egg-info
  running install_scripts
  C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\wheel\pep425tags.py:82: RunOneWorldeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
    warn=(impl == 'cp')):
  C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\wheel\pep425tags.py:87: RunOneWorldeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
    sys.version_info < (3, 8))) \
  creating build\bdist.win-amd64\wheel\mmcv-0.5.8.dist-info\WHEEL
  creating 'C:\Users\OneWorld\AppData\Local\Temp\pip-wheel-93yp2cnh\mmcv-0.5.8-cp37-cp37m-win_amd64.whl' and adding 'build\bdist.win-amd64\wheel' to it
  adding 'mmcv/__init__.py'
  adding 'mmcv/_ext.cp37-win_amd64.pyd'
  adding 'mmcv/version.py'
  adding 'mmcv/arraymisc/__init__.py'
  adding 'mmcv/arraymisc/quantization.py'
  adding 'mmcv/cnn/__init__.py'
etc...
  adding 'mmcv/visualization/optflow.py'
  adding 'mmcv-0.5.8.dist-info/METADATA'
  adding 'mmcv-0.5.8.dist-info/WHEEL'
  adding 'mmcv-0.5.8.dist-info/top_level.txt'
  adding 'mmcv-0.5.8.dist-info/RECORD'
  removing build\bdist.win-amd64\wheel
done
  Created wheel for mmcv: filename=mmcv-0.5.8-cp37-cp37m-win_amd64.whl size=184354 sha256=023fa1fdb01a9fbf7d833975737bc93003c5f1c813ce8c4ae27340b19ddb9cc3
  Stored in directory: c:\users\OneWorld\appdata\local\pip\cache\wheels\cc\7c\4c\a2cc81d990c63b3d157ab3c6e2cc4b5b298c0a4a13e6a46e38
Successfully built mmcv
Installing collected packages: addict, pyyaml, yapf, opencv-python, mmcv, Pillow, terminaltables, mmdet
  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-n1vstot6

  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-qqv40s97

  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-yk9n5qrl

  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-dmbql_3c

  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-6vlnr7x0

  Attempting uninstall: Pillow
    Found existing installation: Pillow 7.1.2
    Uninstalling Pillow-7.1.2:
      Created temporary directory: c:\users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\~il
      Removing file or directory c:\users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pil\
      Created temporary directory: c:\users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\~illow-7.1.2.dist-info
      Removing file or directory c:\users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pillow-7.1.2.dist-info\
      Successfully uninstalled Pillow-7.1.2
  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-thrgvqkj

  Created temporary directory: C:\Users\OneWorld\AppData\Local\Temp\pip-unpacked-wheel-9orxl8mp

  Running setup.py develop for mmdet
    Running command 'C:\Users\OneWorld\anaconda3\envs\open-mmlab2\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OneWorld\\Documents\\DeepLearning\\VideoObjectSegmentation\\mmdetection-2.0.0\\setup.py'"'"'; __file__='"'"'C:\\Users\\OneWorld\\Documents\\DeepLearning\\VideoObjectSegmentation\\mmdetection-2.0.0\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
    running develop
    running egg_info
    writing mmdet.egg-info\PKG-INFO
    writing dependency_links to mmdet.egg-info\dependency_links.txt
    writing requirements to mmdet.egg-info\requires.txt
    writing top-level names to mmdet.egg-info\top_level.txt
    reading manifest file 'mmdet.egg-info\SOURCES.txt'
    writing manifest file 'mmdet.egg-info\SOURCES.txt'
    running build_ext
    building 'mmdet.ops.utils.compiling_info' extension
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\mmdet
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\mmdet\ops
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\mmdet\ops\utils
    creating C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\mmdet\ops\utils\src
    Emitting ninja build file C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\build.ninja...
    Compiling objects...
    Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
    C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py:237: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
      warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
    [1/1] cl /showIncludes /nologo /Ox /W3 /GL /DNDEBUG /MD /MD /wd4819 /EHsc -DWITH_CUDA -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include\TH -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" -c C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\mmdet\ops\utils\src\compiling_info.cpp /FoC:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\mmdet\ops\utils\src/compiling_info.obj -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=compiling_info -D_GLIBCXX_USE_CXX11_ABI=0 /std:c++14
    FAILED: C:/Users/OneWorld/Documents/DeepLearning/VideoObjectSegmentation/mmdetection-2.0.0/build/temp.win-amd64-3.7/Release/mmdet/ops/utils/src/compiling_info.obj
    cl /showIncludes /nologo /Ox /W3 /GL /DNDEBUG /MD /MD /wd4819 /EHsc -DWITH_CUDA -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include\TH -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include -IC:\Users\OneWorld\anaconda3\envs\open-mmlab2\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" -c C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\mmdet\ops\utils\src\compiling_info.cpp /FoC:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\build\temp.win-amd64-3.7\Release\mmdet\ops\utils\src/compiling_info.obj -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=compiling_info -D_GLIBCXX_USE_CXX11_ABI=0 /std:c++14
    CreateProcess failed: The system cannot find the file specified.
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py", line 1400, in _run_ninja_build
        check=True)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\subprocess.py", line 512, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\mmdetection-2.0.0\setup.py", line 300, in <module>
        zip_safe=False)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\setuptools\command\develop.py", line 38, in run
        self.install_for_development()
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\setuptools\command\develop.py", line 140, in install_for_development
        self.run_command('build_ext')
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
        _build_ext.run(self)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
        _build_ext.build_ext.run(self)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\command\build_ext.py", line 340, in run
        self.build_extensions()
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py", line 580, in build_extensions
        build_ext.build_extensions(self)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\Cython\Distutils\old_build_ext.py", line 195, in build_extensions
        _build_ext.build_ext.build_extensions(self)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\command\build_ext.py", line 449, in build_extensions
        self._build_extensions_serial()
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
        self.build_extension(ext)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\setuptools\command\build_ext.py", line 208, in build_extension
        _build_ext.build_extension(self, ext)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\distutils\command\build_ext.py", line 534, in build_extension
        depends=ext.depends)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py", line 562, in win_wrap_ninja_compile
        with_cuda=with_cuda)
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py", line 1140, in _write_ninja_file_and_compile_objects
        error_prefix='Error compiling objects for extension')
      File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py", line 1413, in _run_ninja_build
        raise RunOneWorldeError(message)
    RunOneWorldeError: Error compiling objects for extension
Cleaning up...
  Removing source in C:\Users\OneWorld\AppData\Local\Temp\pip-install-voimjxde\mmcv
Removed build tracker: 'C:\\Users\\OneWorld\\AppData\\Local\\Temp\\pip-req-tracker-6eq3f7le'
ERROR: Command errored out with exit status 1: 'C:\Users\OneWorld\anaconda3\envs\open-mmlab2\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OneWorld\\Documents\\DeepLearning\\VideoObjectSegmentation\\mmdetection-2.0.0\\setup.py'"'"'; __file__='"'"'C:\\Users\\OneWorld\\Documents\\DeepLearning\\VideoObjectSegmentation\\mmdetection-2.0.0\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
Exception information:
Traceback (most recent call last):
  File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pip\_internal\cli\base_command.py", line 186, in _main
    status = self.run(options, args)
  File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pip\_internal\commands\install.py", line 404, in run
    use_user_site=options.use_user_site,
  File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pip\_internal\req\__init__.py", line 71, in install_given_reqs
    **kwargs
  File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pip\_internal\req\req_install.py", line 802, in install
    unpacked_source_directory=self.unpacked_source_directory,
  File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pip\_internal\operations\install\editable_legacy.py", line 51, in install_editable
    cwd=unpacked_source_directory,
  File "C:\Users\OneWorld\anaconda3\envs\open-mmlab2\lib\site-packages\pip\_internal\utils\subprocess.py", line 242, in call_subprocess
    raise InstallationError(exc_msg)
pip._internal.exceptions.InstallationError: Command errored out with exit status 1: 'C:\Users\OneWorld\anaconda3\envs\open-mmlab2\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\OneWorld\\Documents\\DeepLearning\\VideoObjectSegmentation\\mmdetection-2.0.0\\setup.py'"'"'; __file__='"'"'C:\\Users\\OneWorld\\Documents\\DeepLearning\\VideoObjectSegmentation\\mmdetection-2.0.0\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

答案 14 :(得分:-1)

使用

git status 

检查正在发生的事情。

然后

git checkout master 
git merge --squash bugfix
git add (add which files you want or use wildcard command like ".")

然后

git commit -m "message"

最后但并非最不重要

git push -u origin master

origin可以是您喜欢的其他远程设备。