[英]Git (bitbucket) creating backup version
I am wondering what the standard procedure is to create an easy to find stable backup version of a git project. 我想知道创建易于找到的git项目的稳定备份版本的标准过程是什么。 Ideally, it should not be necessary to go through the git logs, find a certain version and revert. 理想情况下,无需遍历git日志,查找特定版本并还原。 Ideally, a version would be tagged. 理想情况下,将对版本进行标记。 I saw git (I am using bitbucket) allows to create branches and some of those branches seem to have a tag release which In like because it indicates it is a stable version. 我看到git(我正在使用bitbucket)允许创建分支,并且其中一些分支似乎具有标记发行版,就像这样,因为它表明它是一个稳定的版本。 Is branching out and switching back to the main branch for further a good way to manage this or are there better solutions available. 正在分支并切换回主分支,以寻求进一步的好方法来管理此问题,或者是否有更好的解决方案可用。 I am not very familiar with git and its mechanics, so I would be happy to get some pointers towards good conventions. 我对git及其机制并不十分熟悉,因此我很乐意获得一些指向良好约定的指示。
You can use git-tag to create tags, with or without annotations. 您可以使用git-tag创建带有或不带有注释的标签。 git tag --list
will show you the available tags, and git-show can be used to view the annotation of a given tag. git tag --list
将显示可用的标签,而git-show可用于查看给定标签的注释。 You then have to push the tags upstream, using git push --tags
or similar. 然后,您必须使用git push --tags
或类似方法将标签推入上游。 For most other purposes, you can treat a tag as a commitish for selecting commits. 对于大多数其他目的,您可以将标签视为选择提交的提交。 For example: 例如:
git tag --annotate --message="Release message 1" release01
git push --tags origin
# code ...
# code ...
git tag --annotate --message="Release message 2" release02
git push --tags origin
# code ...
# code ...
git tag --list
git show release02
# code ...
git reset --hard release01
Pragmatically, you can use the name of a tag almost anywhere you could use a commit ID. 实用上,几乎可以在任何使用提交ID的地方都可以使用标记的名称。 You can use it to reset your branch, as a branch point to create new branches, and so forth. 您可以使用它来重置分支,将其作为创建新分支的分支点,依此类推。
In online services like Bitbucket, GitHub, or GitLab, every tag you create triggers an archive build, which you can download as a zipfile or tarball from the tags/releases widgets. 在Bitbucket,GitHub或GitLab等在线服务中,您创建的每个标签都将触发一个存档版本,您可以从zip / release小部件中将其作为zipfile或tarball下载。 In Bitbucket, you can navigate to your available downloads at: 在Bitbucket中,您可以通过以下网址导航到可用下载:
https://bitbucket.org/<username>/<repository>/downloads/?tab=tags
In Bitbucket, you will see a screen with archives in zip, gzip, and bzip2 format for each tag in the project. 在Bitbucket中,您将看到一个屏幕,其中包含项目中每个标签的zip,gzip和bzip2格式的存档。 Just click the format you want to download it. 只需单击您要下载的格式。
This archive feature is common to most of the popular online Git hosts, but features and navigation to the archives may vary. 大多数常用的在线Git主机都具有此存档功能,但是存档的功能和导航可能会有所不同。 To create the archives locally, just use git-archive from the command line instead. 要在本地创建档案,只需在命令行中使用git-archive即可 。
I'm sure there will be others with more complete answers, but here are some tips: 我敢肯定会有其他人获得更完整的答案,但是这里有一些提示:
v1.1
, v1-stable
, v1-beta
to indicate stable or testing versions, etc. Usually used for marking particular revisions for various purposes (often releases). 您可以制作诸如v1.1
, v1-stable
, v1-beta
类的标签来指示稳定或测试版本等。通常用于标记出于各种目的的特定修订版(通常是发行版)。 master
branch where commits are only merged to it when thoroughly tested, and a dev
branch where main development happens on. 分支:这是提交的并行顺序-许多项目使用的是稳定的master
分支(仅在经过全面测试后才将提交合并到它)和dev
分支(主要开发在此进行)之类的东西。 Used for tracking development, especially when adding new features that require multiple commits, or trying out something different that you don't want in master
. 用于跟踪开发,尤其是在添加需要多次提交的新功能或尝试在master
不需要的其他功能时。 stable
, master
, beta
), and releases are tagged (eg. 1.0.0-beta
, 1.5.0
). 它们具有多个分支(例如stable
, master
, beta
),并标记了发行版本(例如1.0.0-beta
, 1.5.0
)。 You can add a tag and push it to the remote: 您可以添加标签并将其推送到遥控器:
git tag <tagname>
git push origin --tags
This would tag the current commit and push that new tag to the remote you cloned from. 这将标记当前提交并将该新标记推送到您从中克隆的远程服务器。 Checking out a particular branch or commit would let you tag that using this same mechanism. 检出特定的分支或提交将使您可以使用相同的机制对其进行标记。 As stated in other answers, deciding on your tagging strategy is a different matter altogether, but this is the mechanism you use to create the tag and distribute it. 如其他答案所述,决定标记策略完全是另一回事,但这是您用来创建标记和分发标记的机制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.