viper25

Git Workflow

Jun 24th, 2016 (edited)
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. 1.Git Workflow
  2. a.Update the local master branch.
  3. •git pull
  4.  
  5. b.Always create a branch to make a code change (even if it is a single line of code change)
  6. •git checkout -b < new branch name>
  7.  
  8. c.Make your code changes, add them and commit them:
  9. •git add <changed file paths separated by spaces>
  10. •git commit -m "Some meaningful commit message"
  11.  
  12. 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
  13.  
  14. 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
  15. •git checkout master
  16. •git pull --ff-only
  17. •git checkout <new branch name>
  18. •git rebase master
  19.  
  20. f.Rebuild and test rebased code
  21.  
  22. g.Now, push from the branch to the remote master (Once you have tested the code changes)
  23. •git push origin HEAD:master
  24.  
  25. h.Change back to master branch
  26. •git checkout master
  27. •git pull
  28.  
  29. i.Rebuild and test code
  30.  
  31. j.Delete the local branch
  32. •git branch -d < new branch name >
  33.  
  34. k. Keep only last 5 commits.
  35. Create an alias:
  36.  
  37. 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'
  38.  
  39. Run
  40. git rebase-last-five
  41.  
  42. https://stackoverflow.com/questions/11929766/how-to-delete-all-git-commits-except-the-last-five
Advertisement
Add Comment
Please, Sign In to add comment