我知道我可以查看HEAD和当前状态之间的区别meld .
.但是,如何查看分支之间的差异,例如master
和devel
meld?
目前我执行以下步骤:
mv /projectA /projectA_master
)git clone url
devel
分支cd projectA && git -b devel origin/devel
meld /projectA_Master projectA
难道没有一种更简单的方法可以在融合中获得相同的结果吗?我只需要它来审查更改,而不是主要用于合并.
我创建了一个打开几个gnome终端的bash脚本,通过ssh连接到教室计算机并运行脚本.
如何在脚本完成后避免gnome-terminal关闭?请注意,我还希望能够在终端中输入更多命令.
这是我的代码示例:
gnome-terminal -e "ssh root@<ip> cd /tmp && ls"
Run Code Online (Sandbox Code Playgroud) 如何删除已从git历史记录中删除的文件夹?
在我的git存储库中,我有一个名为/foo
(1.2GB大小)的文件夹.我删除了beause 的文件夹foo
,rm -rf /foo
我不再需要了.经过许多其他提交,我想.为什么我的远程回购如此之大......我忘了做git rm --cached ...
而不是做rm -rf ...
.我现在如何从git历史记录中删除该文件夹?
git rm --cached /foo
将无法正常工作,因为该文件夹已在先前的提交中删除.
目前我的python代码通常如下所示:
...
if not dry_run:
result = shutil.copyfile(...)
else:
print " DRY-RUN: shutil.copyfile(...) "
...
Run Code Online (Sandbox Code Playgroud)
我现在考虑写一些像干跑者的方法:
def dry_runner(cmd, dry_run, message, before="", after=""):
if dry_run:
print before + "DRY-RUN: " + message + after
# return execute(cmd)
Run Code Online (Sandbox Code Playgroud)
但是首先执行cmd,然后将结果提供给dry_runner方法.
我如何用pythonic方式编写这样的方法?
我创建了以下类:
class Image(object):
def __init__(self, extension, data, urls=None, user_data=None):
self._extension = extension
self._data = data
self._urls = urls
self._user_data = user_data
self._hex_digest = hashlib.sha1(self._data).hexDigest()
Run Code Online (Sandbox Code Playgroud)
当所有值相等时,图像应该相等.因此我写道:
def __eq__(self, other):
if isinstance(other, Image) and self.__dict__ == other.__dict__:
return True
return False
def __ne__(self, other):
return not self.__eq__(other)
def __lt__(self, other):
return self.__dict__ < other.__dict__
...
Run Code Online (Sandbox Code Playgroud)
但该__hash__
方法应该如何?相等的图像应该返回相等的哈希值...
def __hash__(self):
# won't work !?!
return hash(self.__dict__)
Run Code Online (Sandbox Code Playgroud)
我尝试使用__eq__, __ne__, __lt__, __hash__, ...
推荐的方式吗?