-
Notifications
You must be signed in to change notification settings - Fork 0
Stylitics Git Workflow
Given that you have git installed, it should be fairly easy to clone Stylitics' repo from github:
git clone [email protected]:Stylitics/stylitics.git
We try to avoid merging, it creates ugly merge bubbles and messes up our git history, so we use rebase instead, either do:
git pull origin master --rebase
Or if you prefer a more manual approach, you can do a fetch followed by a rebase which is what pull --rebase
does behind the scenes:
git fetch origin master
git rebase origin/master
When working on features/bugfixes, it's best to checkout a new branch:
git checkout -b your-branch-name
Implement the feature/bugfix in isolation, should you decide to throw your changes away, it would only involve deleting that branch from you local repo.
When you're done working, first, rebase master into your branch:
git rebase master
Then switch to master:
git checkout master
And rebase your branch on top of it:
git rebase your-branch-name
And finally rebase origin/master
one more time to make sure you're up to date and that you resolve all conflicts before you push.
Make sure that while you work on your branch, you rebase as frequently as possible to prevent diverging too much from master
git pull origin master --rebase
When working on a feature/bigfix, it's a best practice to commit early and often, but often times you might end up having 5 or more commits for just one feature, while this is technically fine, we'd rather have a cleaner and more readable history, and that's when git interactive rebase comes into rescue, it lets you squash
any number of commits into just one that represents your feature/bugfix.
Example:
So if you made 5 commits that you want squashed into one, all you have to do is:
git rebase -i HEAD~5
That would bring up your default editor with something along the lines of this:
pick fc62e55 added file_size
pick 9824bf4 fixed little thing
pick 21d80a5 added number to log
pick 76b9da6 added the apply command
pick c264051 Revert "added file_size" - not implemented correctly
Change all instances of pick
into squash
except for the first one, so the above becomes:
pick fc62e55 added file_size
squash 9824bf4 fixed little thing
squash 21d80a5 added number to log
squash 76b9da6 added the apply command
squash c264051 Revert "added file_size" - not implemented correctly
Save your changes, close the editor window and you'll get another window asking you to type in a message for this new commit that contains all the changes from those 5 commits, type a message, save and exit.
To make sure you did everything right, you could do a git log
to see that you now have just one commit with the new message you just typed.
Important: Do not squash commits that have already made public (i.e. pushed to github) becuase that would cause conflicts for the other team members.
For more info: http://book.git-scm.com/4_interactive_rebasing.html
When you want to push your code to our github repo, create a new branch prefixed with your initials:
git checkout -b wa-my-feature
and push that branch, Jenkins will detect your branch automatically and build it in separation from master and other team members' branches, also submit a pull request when your build is green, we will then make sure to pull in your changes.
Our Jenkins instance is on http://ci.stylitics.com