如何将git连接到ClearCase? [英] How to bridge git to ClearCase?

查看:153
本文介绍了如何将git连接到ClearCase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用过 git svn 并非常喜欢它。现在,我正在向另一位客户开始一个新项目。在那个地方,SCM的选择是ClearCase。对于ClearCase,我还没有找到相当于 git svn 的烘焙版本。有没有人曾试图在本地使用git作为ClearCase的前端,使用一些技巧,配置或脚本以及任何成功的措施?如果是的话,你可以解释一下使用的方法吗?

解决方案

这是一个避免劫持的方法,我们的团队非常成功地使用这种方法直到我们退役了Subversion的ClearCase(根据公司政策,尽管这是我们团队的后退步骤 - 我们基本上只是将ClearCase用作哑文件系统,并且实际上在git中本地工作,但现在我们我们使用了两个目录,一个用于ClearCase快照和master git repo,我们共享这个目录的时候使用了git-svn桥,这个桥不像原生git那么好。) 在整个团队中,并且从未编辑过文件,还有一个用于我们的工作目录。



ClearCase快照视图中的准备工作为:

 
%git init
%git add ** / *。cxx ** / *。h ** / Makefile(等等)
%git commit -minitial

然后克隆到您的工作目录中:

 
%mkdir〜/ work
%gi t克隆/路径/到/ repo

在工作目录中,在分支上工作:

 
%git checkout -b功能
%...编辑/编译...
%git add -u
%git commit

确保ClearCase快照是最新的 pristine (这对我们来说总是这样,因为我们在团队中分享了它,并且我们都使用git)。然后通过重新绑定将分支合并到主分支,以避免自动合并提交:

 
%git checkout master
%git pull
%git checkout feature
%git rebase master
%git checkout master
%git合并功能
%git branch -d功能

%git diff --name-状态来源/主

通过检出/ mkelem / rmname任何已更改/新/已删除文件,
基于以下内容来准备ClearCase视图: f git diff --name-status 的输出。我们使用手卷脚本来做到这一点。不要忘记查看任何已添加/删除文件的目录:

然后将git内容重新添加到ClearCase中:

 
%git push
%cd / path / to / repo
%git reset --hard
%cleartool ci`cleartool lsco -r -short -me`

这似乎有很多命令,但这包括设置,并且您的日常工作流程不会使用许多命令。您可以在推回到ClearCase的步骤中轻松构建一个脚本,并随着每个人都习惯于基本的工作流程,逐渐发现/向您的团队展示所有酷炫的额外git材料。



这个系统的真正之处在于,过了一段时间,每个人都可以使用git,可以轻松地清除ClearCase 以及所有相关的猴子工作和费用。也许给该公司的ClearCase家伙一个非常需要的假期和一些节省的再培训。 (可悲的是,在我的公司,git的东西就是所有的skunkworks,我们已经转移到了Subversion--从ClearCase转发,但是从git中退出!)
$ b strong 建议您使用 pristine 脚本2008/08 / clearcase-global-git-local /rel =noreferrer> ClearCase Global,Git Locally ,它在ClearCase快照视图中运行并确保它与git同步。我们将其设置为每天运行两次的cron作业,并且在我们将要推回git时手动运行它。
不幸的是,该博客文章的链接不再有效。不过,该脚本仍可在 Github 上获得。


I've recently used git svn and enjoyed it very much. Now I'm starting a new project at a different customer. At that site the SCM of choice is ClearCase. I haven't found a baked equivalent of git svn for ClearCase. Is there anybody who has tried to use git locally as a front-end to ClearCase using some tricks, configuration or scripting with any measure of success? If so can you please explain the method used?

解决方案

Here's a method that avoids hijacks, which our team used this method quite successfully for over a year, until we retired ClearCase for Subversion (per company policy, although it is a backwards step for our team - we were basically just using ClearCase as a dumb file system, and virtually working natively in git, but now we're using the git-svn bridge which isn't as nice as native git.)

We used two directories, one for the ClearCase snapshot and master git repo, which we shared among the whole team and never edited files in, and one for our "working" directory.

The preparation in the ClearCase snapshot view is:

% git init
% git add **/*.cxx **/*.h **/Makefile (and so on)
% git commit -m "initial"

Then clone in your working directory:

% mkdir ~/work
% git clone /path/to/repo

Work in the working directory, on a branch:

% git checkout -b feature
% ...edit/compile...
% git add -u
% git commit

Make sure the ClearCase snapshot is up-to-date with pristine (which it always was for us, because we shared it among the team, and we all used git).

Then merge the branch onto the master by rebasing it, to avoid an automatic merge commit:

% git checkout master
% git pull
% git checkout feature
% git rebase master
% git checkout master
% git merge feature
% git branch -d feature

% git diff --name-status origin/master

Prepare the ClearCase view by checking out/mkelem/rmname any changed/new/removed files, based off the output of git diff --name-status. We used a hand-rolled script to do this. Don't forget to check out any directories that have added/removed files:

Then push the git stuff back, and check in with ClearCase:

% git push
% cd /path/to/repo
% git reset --hard
% cleartool ci `cleartool lsco -r -short -me`

It seems like a lot of commands, but this includes setup, and your daily workflow doesn't use many commands. You can trivially build a script around the push-back-to-ClearCase step, and discover/show your team all the cool extra git stuff gradually as everyone gets used to the basic workflow.

The real beauty of this system is, after a while when everyone's competent with git, you can trivially ditch ClearCase and all the associated individual monkey work and fees. Maybe give the company's ClearCase guy a much needed holiday and some retraining with the savings. (Sadly at my company the git stuff was all skunkworks, and we've moved to Subversion - forwards from ClearCase but backwards from git!)

I strongly recommend you use the pristine script from ClearCase Globally, Git Locally, which runs in the ClearCase snapshot view and ensures it and git are in sync. We set this up as a cron job that ran twice daily, and also ran it manually whenever we were about to push back to git. Unfortunately the link to the blog post is no longer valid. However the script is still available on Github.

这篇关于如何将git连接到ClearCase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆