Skip to content

Instantly share code, notes, and snippets.

@kamilogorek
Last active December 23, 2015 05:19
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kamilogorek/01a40905aa7158e265bd to your computer and use it in GitHub Desktop.
Our Git Workflow - Forks With Feature Branches
- Initialize new repository
- Create base develop branch
- Fork repository
- Clone your fork locally:
$ git clone [fork-repo-url]
- Add upstream remote:
$ git remote add upstream [main-repo-url]
- Create feature branch diverged from develop branch:
$ git checkout -b [branch-name] develop
- Get your work done and commit it to your repository:
$ git add [files-to-add] or git add -A
$ git commit -m "Commit message"
$ git push origin [branch-name] -u
- Create pull request to main repository
- Ask someone or wait for code review
- Fix your issues or conflicts if there are any
- Get your code merged to the main repository
- When it is time, merge develop branch to release branch by creating a pull request or merging it manually:
$ git fetch upstream
$ git checkout -b release-v0.1 upstream/develop
$ git push upstream release-v0.1
- Test your branch, fix it if necessary by creating fix branches diverged from release:
$ git fetch upstream
$ git checkout -b [fix-branch-name] upstream/release-v0.1
- Make pull requests with fixes, get them passed through code review and merged
- After everything is done, merge release branch to master (or create pull request) and tag it as a next successful milestone in your project:
$ git checkout master
$ git fetch upstream
$ git merge [release-branch]
$ git tag -a release-v0.1
$ git push upstream master
- Repeat whole process
$ git checkout develop
$ git pull upstream develop
$ git merge [branch-name]
(resolve conflicts)
$ git add -A
$ git commit -am "Resolved conflicts"
$ git push upstream develop
$ git checkout [branch-name]
$ git fetch upstream
$ git merge upstream/develop
(resolve conflicts)
$ git add -A
$ git commit -am "Resolved conflicts"
$ git push origin [branch-name]
(function () {
<<<<<<< HEAD
var foo = 'Hello Mom!';
=======
var foo = 'Hey Dad!';
>>>>>>> fix-foo
return foo;
})();
(function () {
var foo = 'Hello Mom!';
return foo;
})();
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: foo.js
$ git remote add [repo-name] [repo-url]
$ git fetch [repo-name] [branch-name]
$ git branch -d [branch-name]
$ git branch -D [branch-name]
$ git push origin :[branch-name]
$ git checkout develop
$ git pull upstream develop
$ git checkout develop
$ git fetch upstream
$ git merge upstream/develop
$ git checkout -b [branch-name] [branch-head]
$ git branch -l
master
* develop
release-v0.1
artf89349
feature-photos-model
fix-videos-controller
$ git fetch upstream master
$ git checkout -b hotfix-gallery-photos upstream/master
$ git checkout master
$ git merge hotfix-gallery-photos
$ git push upstream master (push straight to upstream only if it's really urgent fix)
$ git checkout develop
$ git merge hotfix-gallery-photos
$ ssh user@host
$ git init [path-to-repository.git] --bare
$ mkdir [your-project]
$ cd [your-project]
$ git init
$ git remote add origin [repo-url]
$ touch README.md (to create README file)
$ git add README.md
$ git commit -m "Init commit"
$ git push origin master -u
$ git checkout -b develop
$ git push origin develop -u
$ git clone [forked-repo-url]
$ git remote add upstream [main-repo-url]
$ git checkout [branch-name]
(fix all the issues)
$ git commit -m "Commit message"
$ git push origin [branch-name]
$ git push [repo-name] [branch-name]
$ git fetch upstream develop
$ git checkout -b release-v0.1 upstream/develop
$ git fetch upstream release-v0.1
$ git checkout -b fix-broken-tiles upstream/release-v0.1
$ git checkout master
$ git tag -a release-v0.1
$ git push upstream master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment