简体   繁体   English

使Git提交消息反映已编辑的TFS变更集注释

[英]Make Git commit message reflect edited TFS changeset comment

TL;DR TL; DR

As described in this post , I changed a TFS changeset comment. 正如描述的这个帖子 ,我换了一个TFS变更评论。 How can I get this to be reflected in the corresponding Git commit in my local Git repository, using Git-Tfs? 如何使用Git-Tfs将其反映到本地Git存储库中的相应Git提交中?

Verbose version 详细版本

I'm a Git-Tfs user. 我是Git-Tfs用户。 My workflow is such that I try to commit extremely small increments of code to my local Git repository ("one line change—tests green—commit" sort of thing) and push it up to the TFS server once I have a meaningful (but hopefully still small) changeset. 我的工作流程是这样,我尝试将极少量的代码提交到本地Git存储库(“一行更改-测试绿色-提交”之类的东西),并在有意义时将其推送到TFS服务器(但希望如此)还很小)变更集。 Often this is after just one Git commit, but sometimes it is after several. 通常这只是在一次Git提交之后,但有时是在几次之后。

When checking several Git commits into TFS at once, Git-Tfs combines the Git commit messages as the default TFS check-in comment. 当一次将多个Git提交检查到TFS中时,Git-Tfs会将Git提交消息合并为默认的TFS签入注释。 So far so good. 到现在为止还挺好。 I usually tamper with them to make them a read more smoothly as a single changeset comment. 我通常会篡改它们,以使它们作为单个变更集的注释更顺畅地阅读。 But today I forgot to and checked in a message that would have been less than helpful to my TFS-using coworkers. 但是今天,我忘记了并检查了一条消息,这对使用TFS的同事没有多大帮助。

Okay, no big deal. 好吧,没什么大不了的。 I used TFS to edit the changeset comment to make it more coherent. 我使用TFS编辑变更集注释以使其更连贯。 However, I have not been able to get my local Git repository synced up with this change. 但是,我无法使本地Git存储库与此更改同步。 This is not a big deal, because mainly I changed it for other people. 这没什么大不了的,因为主要是我为其他人更改了它。 However, I am curious to see if I can get it synced up. 但是,我很好奇我是否可以使其同步。

What I've tried 我尝试过的

I tried this, but the commit message is still what it was before I edited the changeset comment: 我尝试了此操作,但是提交消息仍然是编辑变更集注释之前的内容:

git reset --hard HEAD~
git tfs pull

How can I get this to be reflected in the corresponding Git commit in my local Git repository, using Git-Tfs? 如何使用Git-Tfs将其反映到本地Git存储库中的相应Git提交中?

you should understand that due to the fact of how git is build, you CAN'T modify a commit. 您应该了解,由于git是如何构建的,因此您无法修改提交。 Each git commit is "sealed" by its sha1. 每个git提交均由其sha1“密封”。

The only thing that you can do is reset your tfs remote tfs/default to a previous state and fetch the tfs changesets again. 您唯一可以做的就是将tfs远程tfs/default重置为以前的状态,然后再次获取tfs变更集。 I don't even understand what you want to achieve by resetting your local branch!?! 我什至不了解您想通过重置本地分支机构来实现什么! This is always the remotes that reflect the commits of remote repositories and not local branches! 始终是反映远程存储库而不是本地分支的提交的远程! git-tfs don't even care about your local branch. git-tfs甚至不在乎您的本地分支。 The only thing it is looking is the last fetched changeset in your tfs remote (based on the metadata git-tfs-id: written in the commit message of the fetched changeset). 它唯一要查看的是tfs远程中的最后一个获取的变更集(基于元数据git-tfs-id:写入获取的变更集的提交消息中)。

There is a git-tfs command reset-remote to do this reset easily (and safely) with git-tfs since v0.19: 从v0.19开始,有一个git-tfs命令reset-remote可以使用git-tfs轻松(安全)地执行此重置:

git tfs reset-remote HEAD~ #reset the tfs remote to fetch it again
git reset --hard HEAD~ #reset also the local branch to override a git-tfs optimisation when re-fetching changesets
git tfs pull #fetch tfs changesets again

PS: PS:

When checking several Git commits into TFS at once, Git-Tfs combines the Git commit messages as the default TFS check-in comment. 当一次将多个Git提交检查到TFS中时,Git-Tfs会将Git提交消息合并为默认的TFS签入注释。 So far so good. 到现在为止还挺好。 I usually tamper with them to make them a read more smoothly as a single changeset comment. 我通常会篡改它们,以使它们作为单个变更集的注释更顺畅地阅读。

If you want git-tfs to "mirror" your commit in TFS, perhaps you should think about using the git tfs rcheckin command... 如果您想让git-tfs在TFS中“镜像”您的提交,也许您应该考虑使用git tfs rcheckin命令...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM