Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. # Git Cheat Sheet
  2.  
  3. ## Creating a new branch
  4.  
  5. ```bash
  6. git checkout prev_branch # e.g. master, develop, etc.
  7. git checkout -b new_branch # will contain all the history from prev_branch
  8. ```
  9.  
  10. ## Pushing a new branch to GitHub
  11.  
  12. ```bash
  13. git push -u origin branch_name
  14. ```
  15.  
  16. `-u` tells git to create a new branch remotely that our branch will track.
  17.  
  18. ## Merging a feature branch into develop
  19.  
  20. ```bash
  21. git checkout develop
  22. git pull # make sure develop is up-to-date with remote
  23.  
  24. git checkout feature/my_feature # move back to feature branch
  25. git merge develop # merge develop into feature branch, so we can fix any conflicts there
  26. ```
  27.  
  28. At this point one of three things will happen:
  29. - it will "fast-forward" you commits on top of develop
  30. - it will merge using the "recursive strategy" (i.e. make a new merge commit)
  31. - it will conflict and force you to fix the changes, then commit the fixes
  32.  
  33. Once you've dealt with this:
  34.  
  35. ```bash
  36. git checkout develop # move back to develop
  37. git merge feature/my_feature # merge feature into develop
  38. ```
  39.  
  40. This last step shouldn't ever conflict or use the recursive strategy since we already made the fixes on our feature branch.
  41.  
  42. ## Merging develop into master
  43.  
  44. ```bash
  45. git checkout master
  46. git pull # make sure master is up-to-date with remote
  47.  
  48. git checkout develop # move back to develop branch
  49. git merge master # merge master into develop branch, so we can fix any conflicts there
  50. ```
  51.  
  52. At this point one of three things will happen:
  53. - it will "fast-forward" you commits on top of master
  54. - it will merge using the "recursive strategy" (i.e. make a new merge commit)
  55. - it will conflict and force you to fix the changes, then commit the fixes
  56.  
  57. Once you've dealt with this:
  58.  
  59. ```bash
  60. git checkout master # move back to master
  61. git merge develop # merge feature into master
  62. ```
  63.  
  64. This last step shouldn't ever conflict or use the recursive strategy since we already made the fixes on our develop branch.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement