2013-02-18 12 views
22

語境關聯git的使用Team Foundation工作項

用於發展的一個GitHub的企業安裝提交。每個開發者都有自己的公共回購,並且組織擁有授權回購。拉請求用於代碼評論,我們寬鬆地遵循nvie的git flow分支模型。

用於問題跟蹤和部署的TFS安裝(發佈分支)。我們將發佈分支鏡像到TFS回購。

工作項目

現在困難的部分是:我們如何聯繫起來的git提交與TF工作項目(即原本可以在開發商的公共樹枝做)?

我做什麼

我看了下面的項目幫助:

我讀過參考在Git-TF項目中將提交與工作項目相關聯,但我不確定要使用什麼工具以及如何正確地執行該工具。

如果我不得不在發佈分支上運行腳本,我會好的,提交工作條目引用從提交消息中提取出來,並將它們與發送到TFS的變更集相關聯。但是,允許關聯元數據(而不是提交消息)的解決方案將是首選。

我可以選擇將TFS中的工作項與git提交相關聯嗎?

回答

18

使用git-tfs,您可以使用metadatas(甚至強制執行策略!)將工作項關聯到提交消息中。

時提交的在TFS服務器完成(如果你使用rcheckin command

而且甚至有上git的創建一個git音符承諾有工作項的標題他們automaticaly關聯和鏈接工作項目!

但Git和TFS之間的同步過程中使用rcheckin之前,您應該(abolutely)瞭解它是如何工作!

當你在TFS中使用git-tfs進行rcheck提交時,爲每個提交創建相應的tfs變更集並獲取這個變更集的內容來重新創建一個git提交。因此,即使它在正常工作流程中(幾乎)不可見,您在gcheckin之後提交的git提交的內容與原始內容不一樣(修改了歷史記錄!)。

如果這個混帳reporitory被supposted是中央儲存庫,因爲每個commiters將不得不做一個重訂這可能是一個大問題。否則,它不應該成爲一個問題,因爲它是完全透明的,除非特殊情況,但是很容易解決。

不是一個完美的解決方案......

+1

有趣。比我的答案更精確。 +1 – VonC 2013-02-18 14:22:13

+0

Git tfs雖然速度快,但功能卻很強大,但是非常脆弱,而ms git tf卻很有限,但它堅如磐石。 – regisbsb 2015-08-07 13:13:53

+0

@regisbsb錯!我很確定git-tfs和git-tf一樣可靠。唯一的問題是,git-tfs試圖支持git-tf甚至沒有考慮過的分支,因爲TFVC分支的支持是你甚至連想都不想想的最糟糕的混亂。每次我支持一個邊緣案例,還有一個更加愚蠢的支持!如果你想要可靠的使用'--ignore-branches'選項。而已! – Philippe 2015-08-07 20:21:19

6

而不必對這些混帳-TFS工具多的信息,請注意,您可以在任何時間元數據提交補充(改變回購的歷史/ SHA1)通過添加註釋。

請參閱git notes(或Git Tip of the Week: Git Notes)。

通過在專用的「筆記命名空間」中添加該信息,您可以從與Git提交關聯的筆記快速存儲/檢索信息,例如工作項引用。

+0

謝謝,我知道git的筆記,我認爲nodirt Git- TF項目使用它們。但是,這只是答案的一部分。 – Wilbert 2013-02-18 13:26:47

21

如果您使用#在你自己的Git提交信息在git的承諾-m'fixes#123' TFS將自動添加提交符合規定的工作項鍊接項。

+1

是的,這是被引入最新版本的,它會導致問題沒有結束,因爲我們有成千上萬的提交是接受的請求的結果,標題中有'合併請求#142'。這顯然是指GH:E拉請求數字而不是tfs問題。 – Wilbert 2014-02-24 09:45:48

+4

@Wilbert有一種方法可以避免:[pull request merged](https://github.com/git-tfs/git-tfs/pull/513)&[doc](https://github.com/ GIT-TFS/GIT-TFS /斑點/主/ DOC/special-actions-in-commit-messages.md) – Philippe 2014-08-15 12:05:25

3

你應該能夠做到這一點在MS git的TF:

git tf checkin --associate=27631,27637

幫助說:

usage: git-tf checkin [--help] [--quiet|-q|--verbose] [--message|-m=<msg>] [--metadata|--no-metadata] [--renamemode=<all|justFiles|none>] [--deep|--shallow] [--squash=<commit id>|--autosquash] 
[--resolve=<workitem id>] [--associate=<workitem id>] [--mentions] [--no-lock] [--preview|-p] [--bypass|--gated|-g=<definition>] [--keep-author|--ignore-author] [--user-map=[<file path>]] 

Arguments: 
    --help    Displays usage information 
    --quiet, -q, --verbose 
          Determines the output detail level 
    --message, -m=<msg> Use the given <msg> as the changeset comment 
    --metadata, --no-metadata 
          Determine whether to include git commit meta data in the changeset comment when checking in deep. If omitted, value provided during configure is used. 
    --renamemode=<all|justFiles|none> 
          The rename mode to use when pending changes. Specify either "all", "justFiles" or "none" (default: justFiles) 
    --deep, --shallow Creates a "deep" check-in, checking in a TFS changeset for each git commit since the latest TFS changeset(requires linear history or "--squash" or "--autosquash"), or 
          "shallow", checking in a single changeset for all commits.If omitted, the depth value provided during clone or configure is used. 
    --squash=< commit id>, --autosquash 
          Specifies how check in should operate in the deep mode if one commit has more than one parent 
    --resolve=< workitem id> 
          ID of the TFS work item to resolve during check-in 
    --associate=< workitem id> 
          ID of the TFS work item to associate during check-in 
    --mentions Add references in the commit comments for any work items linked to the corresponding changeset. 
    --no-lock    Does not take a lock on the server path before committing (dangerous) 
    --preview, -p Displays a preview of the commits that will be checked in TFS 
    --bypass, --gated, -g=<definition> 
          Bypass gated check-in or specify a gated build<definition> to use 
    --keep-author Use the commit author as the changeset owner when checking in deep.The commit author should be known to TFS either by his name or e-mail address.To use this option you should 
       be either a TFS project administrator or have the "Check in other users' changes" permission. 
    --ignore-author Use the current authenticated user as the changeset owner. 
    --user-map=[< file path >] 
          Specifies an absolute or relative path to a file providing mapping between Git repository commit authors and TFS user identities. (default: ./USERMAP) To generate a template 
          mapping file, run the checkin command in preview mode with the --keep-author and --deep options specified. 

Creates a check-in of the changes in the current master branch head, provided it is parented off a commit converted from a TFS changeset. 
相關問題