git和C ++工作流,如何处理对象和归档文件? [英] git and C++ workflow, how to handle object and archive files?

查看:152
本文介绍了git和C ++工作流,如何处理对象和归档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git与SVN存储库接口。我有几个git分支为我工作的不同的项目。



现在,每当使用'git checkout'从一个分支切换到另一个分支时,所有编译的可执行文件和上一个分支的目标文件仍然存在。我想看到的是,从分支A切换到B导致一个树,所有对象文件和二进制文件从我上次在分支B工作。



有一种方法来处理这个而不创建多个git仓库?



更新:我知道可执行文件和二进制文件不应该存储在存储库中。我有点失望的事实,所有分支的东西在git对我没用,事实证明,我必须克隆我的代理git仓库为每个分支,我想开始。我已经为SVN做了一些事情,希望用git避免。当然,我不必这样做,但是这将导致我在大部分时间之间切换分支(不是乐趣)后做一个新的。

解决方案

你想要的是一个完整的上下文,而不仅仅是分支...这是一个版本控制工具的范围一般。最好的方法是使用多个仓库。



不要担心这样的低效率...让你的第二个仓库克隆第一个仓库。 Git会自动使用链接,以避免在磁盘上有多个副本。



这里有一个黑客想要你想要的
$ b

因为你有单独的obj目录,你可以修改你的Makefile,使基本位置动态使用这样:

  OBJBASE =`git branch --no-color 2> / dev / null | sed -e'/ ^ [^ *] / d'-e's / * \(。* \)/ \1\ //'
OBJDIR =$(OBJBASE).obj
#branch master:OBJBASE ==master /,OBJDIR ==master / .obj
#非git checkout:OBJBASE ==,OBJDIR ==.obj

这将把你的分支名称改成OBJBASE,你可以使用它来构建你的实际objdir位置。我会留给你修改它以适应你的环境,并使它友好的非git用户的Makefile。


I use git to interface with an SVN repository. I have several git branches for the different projects I work on.

Now, whenever I switch from one branch to another using 'git checkout ', all the compiled executables and object files from the previous branch are still there. What I would like to see is that switching from branch A to B results in a tree with all object files and binaries from the last time I worked on branch B.

Is there a way to handle this without creating multiple git repositories?

Update: I understand that executables and binaries should not end up in the repository. I'm a bit disappointed in the fact that all the branching stuff in git is useless to me, as it turns out I'll have to clone my proxy git repository for every branch I want to start. Something I already did for SVN and hoped to avoid with git. Of course, I don't have to do it, but it would result in me doing a new make most of the time after switching between branches (not fun).

解决方案

What you want is a full context, not just the branch... which is generally out of scope for a version control tool. The best way to do that is to use multiple repositories.

Don't worry about the inefficiency of that though... Make your second repository a clone of the first. Git will automatically use links to avoid having multiple copies on disk.

Here's a hack to give you want you want

Since you have separate obj directories, you could modify your Makefiles to make the base location dynamic using something like this:

OBJBASE = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1\//'`
OBJDIR = "$(OBJBASE).obj"
# branch master: OBJBASE == "master/", OBJDIR == "master/.obj"
# non-git checkout: OBJBASE == "", OBJDIR == ".obj"

That will but your branch name into OBJBASE, which you can use to build your actual objdir location from. I'll leave it to you to modify it to fit your environment and make it friendly to non-git users of your Makefiles.

这篇关于git和C ++工作流,如何处理对象和归档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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