-
Notifications
You must be signed in to change notification settings - Fork 6
Git Workflow
Sergey Piterman edited this page Jan 21, 2016
·
8 revisions
- Did I create my work branch off of master (didn't cut new branches from existing feature branches)?
- Did I follow the correct naming convention for my branch?
- Is my branch focused on a single main change?
- Do all of my changes directly relate to this change?
- Did I rebase the upstream master branch after I finished all my work?
- Did I write a clear pull request message detailing what changes I made?
- Did I get a code review?
- Did I make any requested changes from that code review?
###Make a fork Create a fork from the main repo to your github profile. Clone the repo to your machine from your fork. Do not clone from the main repo.
###Add a remote After pulling down the repo, add a remote: git remote add upstream [git url of the master repo]
###Make your own branch git checkout -b [name of your branch]
###Commit and rebase git pull --rebase upstream development
$ git checkout -b feat-branch upstream/development
Branch development set up to track remote branch development from origin.
Switched to a new branch 'feat-branch'
$ git branch -a
$ git pull --rebase upstream development
From https://github.com/mks-greenfield/trendr
* branch development -> FETCH_HEAD
Already up-to-date.
$ git add -A
$ git status
$ git commit -m "[feat] Add feature"
$ git pull --rebase upstream development
$ git push origin feat-branch
- Create a feature branch from master.
git checkout -b [name_of_your_new_branch]
- Prefix your branch name with what you are working on:
- Example:
feat-authentication
- bug-...
- cleanup-...
- doc-...
- feat-...
- refactor-...
- test-...
- Example:
- View all branches:
git branch -a
- To create a branch off a remote branch that is not master:
git checkout -b [name_of_your_new_branch] origin/[name of remote branch]
- Commit every time you implement a working piece of your program. Try not to add 10 lines of code in 1 file and 20 lines in another unrelated file before committing once.
- To stage files to commit, you can cover your bases by using
git add -A
. However you can use any of the following:
-
git add -A
: Stage all (new, modified, deleted) files. -
git add .
: Stage new and modified files only. -
git add -u
: Stage modified and deleted files only. -
git add [filename]
: Stage specific file.
- Use
git status
to verify that you've staged all files you wanted to change. -
git commit
to add changes.
- Commit your changes to your local branch
- Rebase from upstream:
$ git pull --rebase upstream development
- Run git status to see what files have merge conflicts
- Handle merge conflicts within those files
- For each file you resolve the conflicts for:
$ git add [filename]
- Continue the rebase:
$ git rebase --continue
- Push to your branch on your fork:
$ git push origin [branch name]
- Interactive Tutorial covering a walk through of forks and pull requests: http://jlord.us/git-it/
- MakerSquare's resource: http://bookstrap.makersquare.com/curriculum/git-workflow-overview