Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.Git Workflow
- a.Update the local master branch.
- •git pull
- b.Always create a branch to make a code change (even if it is a single line of code change)
- •git checkout -b < new branch name>
- c.Make your code changes, add them and commit them:
- •git add <changed file paths separated by spaces>
- •git commit -m "Some meaningful commit message"
- d.Build and test the code changes, If code changes are required, fix code until it builds and successfully runs the tests. Then git add and git commit again
- e.Are the changes up-to-date with remote master? if not, than before trying to push the code to remote master, update the local repo
- •git checkout master
- •git pull --ff-only
- •git checkout <new branch name>
- •git rebase master
- f.Rebuild and test rebased code
- g.Now, push from the branch to the remote master (Once you have tested the code changes)
- •git push origin HEAD:master
- h.Change back to master branch
- •git checkout master
- •git pull
- i.Rebuild and test code
- j.Delete the local branch
- •git branch -d < new branch name >
- k. Keep only last 5 commits.
- Create an alias:
- git config --global alias.rebase-last-five '!b="$(git branch --no-color | cut -c3-)" ; h="$(git rev-parse $b)" ; echo "Current branch: $b $h" ; c="$(git rev-parse $b~4)" ; echo "Recreating $b branch with initial commit $c ..." ; git checkout --orphan new-start $c ; git commit -C $c ; git rebase --onto new-start $c $b ; git branch -d new-start ; git gc'
- Run
- git rebase-last-five
- https://stackoverflow.com/questions/11929766/how-to-delete-all-git-commits-except-the-last-five
Advertisement
Add Comment
Please, Sign In to add comment