I want to ask if the following workflow is correct!
It is referring to a small private team.
There is a master branch where no one merges there ( except the maintainer ),
a development branch and individual branches for every user. So,every user will push to development branch.
So:
* clone the repo to your local machine
git clone https://github.com/username/project.git
* cd project
* git remote add upstream https://github.com/group/project.git
* git checkout userbranch
* git add files
git commit -m ".."
* git push origin userbranch ( I am not sure if this step is necessary since I
* Merge into development and push your work to development
git checkout development
git merge --no-ff userbranch
git push origin development
* Update local master to apply changes from master to the local repository.
git checkout userbranch ( or checkout local master? )
git fetch upstream
git merge upstream/development
* git push origin development
I am not sure if all the sequence is right (I don't want to make any mistakes!). Also, I am not sure about the steps where I say Update local master to apply changes from master to the local repository
and Merge into development and push your work to development
if they work as expected.
And at the last step do I have to checkout on my branch or my local master?
And finally , (if the above is correct ) at which point do I fetch and merge from master branch?Generally,how can I combine master and development branches?
Best Answer
Your question should involve description of your delivery and development process, and then you could decide which branches you need to maintain.
I assume a classical set-up. You have a main development branch - where everything is developed by default, and a release branch, which is what you are preparing to publish as a release to customers.
For a default development branch is better to use
master
branch, as it is default branch, so developers could work on it straight away. For releases create a branchrelease
. The workflow for a developer is following:git clone https://github.com/username/project.git
cd project
git add files/git commit
git pull, git push
go to 3.
For a release manager during release:
git checkout release
git merge master
git tag v1.2.3.4
git push && git push --tags
"Userbranches" will be local branches in dev's clones (or in forks), so usually you don't need to do anything special about it, no special names. It's easier when branch names match.
This is the very basic scenario, if you need some more options, e.g. doing hotfixes or feature branches, you could build all of it on top of this base.
If you need a code-review (only a designated person could merge code from devs into master), then you need forks. The forks in github are for pull-requests. So, user pushes his work into a fork and sends a pull request to the designated person.