diff --git a/README.md b/README.md index 8116361..9670f8b 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Each new feature should reside in its own branch using `feature/` prefix, But in #### Creating a feature branch `git checkout master` -`git pull origin master` +`git pull --ff-only origin master` `git checkout -b feature/my_feature` #### Finishing a feature branch @@ -36,7 +36,7 @@ Each new feature should reside in its own branch using `feature/` prefix, But in When you’re done with the development work on the feature, the next step is to merge the `feature/my_feature` into `staging` to show it Client and QA for their approval. `git checkout staging` -`git pull origin staging` +`git pull --ff-only origin staging` `git merge --no-ff feature/my_feature` `git push origin staging` @@ -45,7 +45,7 @@ When you’re done with the development work on the feature, the next step is to After Client's approval, the next step is to merge the `feature/my_feature` into `master` to deploy it production server `git checkout master` -`git pull origin master` +`git pull --ff-only origin master` `git merge --no-ff feature/my_feature` `git push origin master` @@ -61,22 +61,28 @@ Once it get deployed to prodction, the next step is to delete local and remote b `hotfix` branches are used to quickly patch for production. This branch that should fork directly off of `master`. As soon as the fix is complete, it should be merged into both `master` and `staging`. `git checkout master` -`git pull origin master` +`git pull --ff-only origin master` `git checkout -b hotfix/my_fix` Similar to finishing a feature branch, a hotfix branch gets merged into both `master` and `staging`. `git checkout master` -`git pull origin master` +`git pull --ff-only origin master` `git merge --no-ff hotfix/my_fix` `git push origin master` `git checkout staging` -`git pull origin staging` +`git pull --ff-only origin staging` `git merge --no-ff hotfix/my_fix` `git push origin staging` +## Things to note +* Always use `--ff-only` when pulling changes from remote, otherwise it creates a merge commit, which pollutes history. Then you can rebase your local branch over remote and push accordingly. +* If a change is going to take 3 or more commits, it should not be in a hotfix branch +* When doing a merge you should always use `--no-ff` to create an additional commit. This helps to group related commits together. + + ## Useful git configuration Git configuration can help you a lot with the projects. Here are a few useful options- * `push.default=current` - When typing `git push` without any branch name, it will push the current branch automatically.