在github上维护同一项目的两个不同版本的正确方法是什么?

时间:2016-12-24 06:27:03

标签: php git github laravel-5 version-control

我必须说是Git和Github的新手,我提前为这样一个基本问题道歉。我创建了我的第一个PHP"幼虫包"在GitHub上的项目。我做了多次提交,并使用Gi​​t Bash将它们推送到GitHub上。

现在我的代码足够稳定并处于生产准备阶段。我怎样才能让每个人都下载它?

有一次,第一个版本可供下载,我想为开发制作另一个版本,我将为下一个版本添加更多功能。

我想最终得到至少稳定的版本和另一个开发版本。如果有人报告我的生产版本中的错误,我希望能够修补它并仅提交到生产中的版本"因此没有任何新的未来作为开发者将被包含在补丁中#34;

适应这种情况的最佳方法是什么?我可以使用哪些命令来创建和轻松维护同一项目的多个版本,我可以在一个版本中添加新功能,而只向另一个版本添加补丁?

3 个答案:

答案 0 :(得分:1)

执行此操作的最佳方法是分支。

在您的情况下,这意味着有一个名为master(默认)和develop的分支(或沿着这些行的东西)。

This tutorial有助于获得分支机构。

要创建新分支,请使用git branch [name]

要切换到该分支,请使用git checkout [name]

您需要在develop分支上进行开发。当develop分支处于您要发布的状态时,您可以merge将其转换为master,从而将新更改推送到生产分支。

如果您对此工作流程有疑问,请与我联系,我可以尝试回答。

答案 1 :(得分:1)

这是一种简单的方法

  1. 你在master分支上工作并提交。如果有人给你一个Pull Request,你可以将代码合并到master。

  2. 一旦您认为代码已准备好发布,请按git branch release_vX.Y.Z创建一个版本名称的新分支。

  3. 在您测试代码时,修复发布分支上的错误,然后通过git cherry-pick

  4. 选择对主分支的更改
  5. 通过git tag在发布提交上创建标记。

  6. 如果您从事大型项目,最好的方法是

    1. 您在dev之类的个人分支机构工作,请随时登记并将代码提交到dev分支机构。

    2. 如果有人创建了Pull请求,请将其代码合并到master。

    3. 完成工作后,将所有更改提交到dev分支。然后

      3.1 master分支git checkout master && git pull分支与dev的github 3.2将您的git checkout dev; git rebase origin/master分支机构改为dev的最新更改。您可能需要解决冲突并提交。 3.3将所有git reset master提交合并到一个提交。 git add会将提交日志重置为master但保留更改,然后git commit所有更改和dev以创建新的单个提交。 3.4将您的master更改合并到git checkout master; git merge dev分支git tag release_vX.Y.Z

    4. 如果您认为代码足够稳定,则可以创建测试和错误修复的版本。如果没有测试或错误修复,那么您可以通过public TApplicationDocument getDocumentById(int id) { TypedQuery<TApplicationDocument> q = getEntityManager().createQuery( "FROM TApplicationDocument where transientKey = :transientKey", TApplicationDocument.class); q.setParameter("transientKey", id); TApplicationDocument d=null; try { d = q.getSingleResult(); System.out.println("AppDocumentTitle "+d.getAppDocumentTitle()); } catch (NoResultException e) { logger.debug("No result forund for... "+id); System.out.println("No result forund for... "+id); } catch (Exception e) { logger.debug(" Tapp Dao IMple Exception for... "+id); } return d; } 在提交时创建发布标记。

    5. Atlassian有一个很好的文档,关于基于Git的一般软件开发的git工作流程。这是链接https://www.atlassian.com/git/tutorials/comparing-workflows

答案 2 :(得分:0)

<强>分支机构

您可以使用production分支进行开发,也可以使用单独的分支(例如tag)来合并一些主提交。为了跟踪不同的版本,您可以releases

使用GitHub,您可以制作-(UIImage *)resizeImage:(UIImage *)image { float h=200; float w=400; float actualHeight = image.size.height; float actualWidth = image.size.width; float maxHeight = h; float maxWidth = w; float imgRatio = actualWidth/actualHeight; float maxRatio = maxWidth/maxHeight; float compressionQuality = 0.8;//50 percent compression if (actualHeight > maxHeight || actualWidth > maxWidth) { if(imgRatio < maxRatio) { //adjust width according to maxHeight imgRatio = maxHeight / actualHeight; actualWidth = imgRatio * actualWidth; actualHeight = maxHeight; } else if(imgRatio > maxRatio) { //adjust height according to maxWidth imgRatio = maxWidth / actualWidth; actualHeight = imgRatio * actualHeight; actualWidth = maxWidth; } else { actualHeight = maxHeight; actualWidth = maxWidth; } } CGRect rect = CGRectMake(0.0, 0.0, actualWidth, actualHeight); UIGraphicsBeginImageContext(rect.size); //UIGraphicsBeginImageContextWithOptions(rect.size,NO,0.0); [image drawInRect:rect]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); NSData *imageData = UIImageJPEGRepresentation(img, compressionQuality); UIGraphicsEndImageContext(); return [UIImage imageWithData:imageData]; } ,它们基本上是回购的快照。