Branches: Difference between revisions
No edit summary |
No edit summary |
||
Line 27: | Line 27: | ||
== |
==Create a new development branch from master== |
||
<pre> |
<pre> |
||
Line 34: | Line 34: | ||
</pre> |
</pre> |
||
== |
==Develop code== |
||
The develop branch is used for continuous code development and for working out conflicts when merging features that were on a separate branch. Only when the code is functional enough can it be considered as a release candidate (see Releases below). |
The develop branch is used for continuous code development and for working out conflicts when merging features that were on a separate branch. Only when the code is functional enough can it be considered as a release candidate (see Releases below). |
||
=== |
===Set up develop environment=== |
||
When developing code for a website, it may be wise to clone the project into a new folder so as not to mess with the live/production 'master' environment |
When developing code for a website, it may be wise to clone the project into a new folder so as not to mess with the live/production 'master' environment |
||
<pre> |
<pre> |
||
Line 53: | Line 53: | ||
</pre> |
</pre> |
||
=== |
===Commit code=== |
||
After you have developed your code and completed some logical component it is wise to commit the changes to the repository to make it easier for future code revision and debugging. |
After you have developed your code and completed some logical component it is wise to commit the changes to the repository to make it easier for future code revision and debugging. |
||
<pre> |
<pre> |
||
Line 60: | Line 60: | ||
</pre> |
</pre> |
||
=== |
===Upload commit to server=== |
||
When a remote repository is available it is good practice to also upload the latest commit so everyone else can get access to the most recent changes in code. |
When a remote repository is available it is good practice to also upload the latest commit so everyone else can get access to the most recent changes in code. |
||
<pre> |
<pre> |
||
Line 67: | Line 67: | ||
== |
==Releases== |
||
When the code in the develop branch is functional and without major bugs it can be considered as a release candidate. Code in the release branch can still contain bugs, but it's intended to fix only the current bugs and not introduce new features. Once the release has been thoroughly tested and all known bugs are squashed it can be brought over to the main branch (see Stable branch below). |
When the code in the develop branch is functional and without major bugs it can be considered as a release candidate. Code in the release branch can still contain bugs, but it's intended to fix only the current bugs and not introduce new features. Once the release has been thoroughly tested and all known bugs are squashed it can be brought over to the main branch (see Stable branch below). |
||
=== |
===Create Release branch=== |
||
If not done so already, create a new Release branch from develop. |
If not done so already, create a new Release branch from develop. |
||
Line 84: | Line 84: | ||
== |
==Stable== |
||
When finishing touches on the release branch have completed it's time to merge the code of the release branch into the master branch. The master branch is where only stable code releases should live. This keeps the branch clean from development work and commit comments. |
When finishing touches on the release branch have completed it's time to merge the code of the release branch into the master branch. The master branch is where only stable code releases should live. This keeps the branch clean from development work and commit comments. |
||
Revision as of 02:58, 9 February 2024
Git branch model
- develop
- feature
- release
- master
Some basic rules for successful development using branches:
- master only gets updated from release
- develop is the main working branch
- develop is the source for new releases and features
- features can only go back into develop
resource: https://nvie.com/posts/a-successful-git-branching-model/
Create a new development branch from master
git branch develop git push --set-upstream origin develop
Develop code
The develop branch is used for continuous code development and for working out conflicts when merging features that were on a separate branch. Only when the code is functional enough can it be considered as a release candidate (see Releases below).
Set up develop environment
When developing code for a website, it may be wise to clone the project into a new folder so as not to mess with the live/production 'master' environment
git clone git@gitserver:myproject myproj_dev cd myproj_dev git checkout develop
If the development branch and work environment has already been created, then simply checkout the code:
cd myproject_dev git checkout develop
Commit code
After you have developed your code and completed some logical component it is wise to commit the changes to the repository to make it easier for future code revision and debugging.
git add . git commit -m <commit message>
Upload commit to server
When a remote repository is available it is good practice to also upload the latest commit so everyone else can get access to the most recent changes in code.
git push
Releases
When the code in the develop branch is functional and without major bugs it can be considered as a release candidate. Code in the release branch can still contain bugs, but it's intended to fix only the current bugs and not introduce new features. Once the release has been thoroughly tested and all known bugs are squashed it can be brought over to the main branch (see Stable branch below).
Create Release branch
If not done so already, create a new Release branch from develop.
git branch release git push --set-upstream origin release
If the release branch has already been created, then simply checkout the release branch
git checkout release
Stable
When finishing touches on the release branch have completed it's time to merge the code of the release branch into the master branch. The master branch is where only stable code releases should live. This keeps the branch clean from development work and commit comments.
git checkout master git pull origin master git merge release git push origin master