Anything in
masterbranch is always deployable
Read the github post <Understanding the github flow> before start this tutorial.
Making changes on a repository consists following steps
- Stage
- Commit
- Push
Create a repository
You can either create a brand-new repository directory from scratch or use some template for better project management.
Example templates:
Collaboration with group member
Invite the collaborator
navigate to the setting under the repository webpage, add the collaborator as shown in the figure.
Collaborator contribute
If you are vscode user, there is git GUI for workflow management.
When the collaborate contribute, they normally create a new branch.
- Keep the
masterbranch up-to-date.$ cd </path-to-the-repository> $ git pull - Create a new branch from the master branch, and work on it
$ git checkout -b <name-of-new-branch>which is equivalent as
$ git branch <name-of-new-branch> $ git checkout <name-of-new-branch> - working on the new feature locally, and dont forget to push it to the remote server (allow others see your code).
$ git push origin <name-of-new-branch> - Merge the created branch to
masterbranch, then delete the branch.$ git checkout master # change to the master branch $ git merge <name-of-new-branch> $ git commit $ git push $ git branch -d <name-of-new-branch>
Branch types

Recommand to use git-flow for branch organization. Use this tutorial for gitflow.
masterbranch:perform tagging and release on this branch.developbranch: checkout frommasterbranch. This branch normally won’t be modified directly, instead it checkout new feature branches, then merge them back on thisdevelopbranch.releasebranch: checkout fromdevelopbranch. This branch is used for the test before version release, with minor bug fix. If bug fix is complicated, merge back to the develop branch then may working from other branches. After this branch is well-tested, merge it back to both develop and master branch.featurebranch: checkout fromdevelopbranch. Every team-member host independentfeaturebranches for feature development. When the development is done, merge it back todevelopbranch.fixbranch: checkout fromdevelopbranch for bug fix. After the bug is fixed, merge it back to the develop branch, then delete thisfixbranch.hotfixbranch: checkout frommasterbranch for bug fix. After the bug is fixed, merge back to bothmasteranddevelopbranch, then delete thishotfixbranch.
Exmaple commands in git-flow
$ git flow init # initialization with git-flow
$ git flow feature start <feature_branch>
$ git flow feature finish <feature_branch>
$ git flow release start <0.1.0>
$ git flow release finish '0.1.0'
Other commands to be used
Commands for branch management:
$ git branch # show local branches
$ git branch -a # show local and remote branches
$ git branch -d <name-of-new-branch> # delete the local branch
$ git branch -D <name-of-new-branch> # force delete the local branch
$ git push <remote_name> --delete <branch_name> # delete remote branch$ git push <remote_name> :<branch_name>
$ git push <remote_name> :<branch_name> # delete remote branch
The remote name can be shown by:
$ git remote # the remote is <origin> in github
Include a third-party repository in the current repo
We follow the commands described in this post using git submodule:
git submodule add https://github.com/ufoym/imbalanced-dataset-sampler
Moreover, a very important setting of the 3rd-party repo (fork the repo but can sync with the original repo) is discussed in the this post.
Other useful tutorials
Basically, I rank the tutorial based on the value I found in it: