Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlosmid/a0d4923cd0cb34cbd795 to your computer and use it in GitHub Desktop.
Save karlosmid/a0d4923cd0cb34cbd795 to your computer and use it in GitHub Desktop.
Tentamen git workflow

Note: please use git manual to get to know what each git command is actually doing. Divide feature on which you are working in short working deliverables. That means when you are done with your implementation and unit testing, you can merge to master branch and delete your small feature branch.

Clone repository (repository will be called repo furthermore in this wiki.)

mkdir ~/repos
cd repos
git clone git_repository
cd git_repository

Get latest code from remote

git status
git checkout master
git pull --rebase

Start working on feature_name. Be sure that feature scope is small as possible. We want your contribution to master as soon as possible!

git branch -a List of all repo branches, remote and local
git checkout -b feature_name Creates feature branch with name feature_name from master branch
git status
git push -u origin feature_name put feature branch to remote repo

Do your work in feature branch. Commit as much as possible.

git checkout feature_name To be sure that you are in appropriate feature branch.
git add .
git commit -m 'something useful and funny'

Send commits to remote repo branch

git rebase -i @{u}
git push -u origin feature_name

Code is ready for master after a lot of testing!

git checkout master
git merge --no-ff feature_name
grep -H -r '<<<<<<< HEAD' * | less -check for conflicts. Resolve them using your favourite editor
git add edited_file -skip if there was no conflicts
git commit -m 'merge from to'
git rebase -i @{u}
git push -u origin master

More on that topic could be found here.

Thank, you feature_name branch, we are done! Your life must be shorter than butterflies!

git push origin :feature_name
git branch -d feature_name
git remote prune origin - in order to sync with origin for branches deleted from other computer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment