Tra*_*mes 7 git version-control
多年来我使用了大约10个版本的控制系统.我正在转向Git,几天前我从未使用过它.(通过SSH获取"公共"回购)
我不是在问如何使用Git,而是如何构建存储库,或者如果我需要多个或什么.我有多个涉及多个库的项目.我想版本标记库,以便我可以轻松维护这样的东西:
项目A,2012年发布
主项目源,版本1.0,当前开发版本
Lib-A,版本1.0
Lib-B,版本2.0
Lib-C,当前开发版本
项目B,即将发布,更新至1.0
主项目源,版本2.0,当前开发版本
Lib-A,版本2.0,当前开发版本
Lib-B,版本1.0
Lib-C,当前开发版本
我的想法是,我可以将所有需要构建项目A和B的内容下载到目录中 - 具有当时可能具有的任何要求 - 能够使用当前开发版本,或保留旧版本(例如:项目B中的Lib-B是旧版本,目前尚未更新,或者如果它是分支.)
最初,我正在考虑(In Repo)的内容:
/ Src /项目A
/ Src /项目B
/ Src/Lib/LibA
/ Src/Lib/LibB
/ Src/Lib/LibC
在这种情况下,我必须将它们归结为与归档中存在的结构不同的结构,或者至少将它们放入不同的目录中,或者:
/ Src/ProjectA/A
/Src/ProjectA/LibA
/Src/ProjectA/LibB
/Src/ProjectA/LibC
/Src/ProjectB/B
/Src/ProjectB/LibA
/Src/ProjectB/LibB
/Src/ProjectB/LibC
或
// Src/ProjectA
/Src/ProjectB
/Src/Lib/LibA
/Src/Lib/LibB
/Src/Lib/LibC
(抱歉格式不好,我试着说服这不是代码)
但是使用这种结构,当你从项目A切换到B的开发时,你需要切换Lib目录......不是我想做的事情.
在我看来,为了在GIT中这样做,我想要多个Git repo,也许每个Lib一个
我最近被告知第一个选择,将多个版本带到不同的位置,这将是一个坏主意.(他在SVN下谈论,所以可能不适用),我工作的公司几年前在Source Safe下做过这种事情并且工作得很好 - 我们能够创建一个指定每个lib的版本标签的文件关闭并使用NANT脚本来获取正确的版本,并可以根据需要更新它们.(不知道这里最简单的方法是,最初,它会更简单.就像一个文件说明它需要什么版本或者其他东西)可以做的另一件事是在所有项目中应用标签A的发布源代码如下:"RELEASE_1_0_PROJECT_A"并根据该版本标签降低所有源代码.(标签或任何你想称之为的东西)
但是,有了Source Safe,标签只会跨越该位置及其下方,而不是整个仓库.
我还在他们工作的地方分支代码并创建一个新的顶级树,例如:
/ dev/x64 Branch/ProjectA(结构的其余部分与第二个示例相同.
和/ dev/trunk/ProjectA(结构的其余部分与第二个示例相同.)
在这种情况下,要同时处理A和B,您将拥有该项目所需的一切分支,项目A分支和项目B分支.
建议?
更新:(本来可以在下面作为评论,但StackOverflow溢出,不会让我发表评论很长)
好的,我做到了,结果是:
Project\
Libs\
LibA
LibB
I created it with:
git add submodule ../Lib/LibA ./Libs/LibA
git update --init
Modified a file, and then tried to push it:
git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 378 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, **updating the current branch in a non-bare repository
remote: error: is denied,** because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /src/C#/Lib/TraderhutLib
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to...
Run Code Online (Sandbox Code Playgroud)
评论:"默认情况下,更新非裸存储库中的当前分支会被拒绝,因为它会使索引和工作树不一致......"
听起来好像我会LOL关于某人发表评论 - 基本上,它听起来像是说:"你只能将文件签入一个空的.Git Repo,因为否则我们会弄乱你的工作目录,使其与你刚检查的内容不匹配".
所以,我的新问题:我如何检查更改?什么是简单/匹配的东西?我使用哪个(看起来它给了我命令,使其成为默认值.)
谢谢.
听起来您想使用子模块。
您将有五个存储库:
项目 A 将有三个子模块,每个库一个。项目 B 也有三个子模块,每个库一个。
当您克隆一个项目时,您将确保使用--recursive正确的版本(如果需要,不同项目的不同版本),您也会检查所有库源。更新库代码时,您需要将更改提交到项目代码中,以便项目使用新版本的库。
子模块通过在父项目中存储对子模块版本的 SHA-1 的引用来工作。因此,项目 A 的 1.0 版将引用abc123...Lib A 的提交,这对应于 Lib A 的 1.0 版。当您签出项目 A 时,您将自动获得 Lib A 的 1.0 版。
| 归档时间: |
|
| 查看次数: |
2633 次 |
| 最近记录: |