└── README /README: -------------------------------------------------------------------------------- 1 | ########## 2 | # BASICS # 3 | ########## 4 | 5 | To make changes: 6 | 7 | git add path/to/file1 path/to/file2 8 | git commit -m "templates: Changed the XX template to do XX" 9 | 10 | To push that to the central server (which makes it available for deployment): 11 | 12 | git push 13 | 14 | To revert a file to its state in the repository: 15 | 16 | git checkout path/to/file_that_has_changed 17 | 18 | To get the latest code changes: 19 | 20 | git pull --rebase 21 | 22 | ############################# 23 | # REMOTE BRANCHES: YOUR OWN # 24 | ############################# 25 | 26 | We use remote tracking branches for branching. 27 | 28 | To create a tracking branch called "ajax_fallback": 29 | 30 | git checkout -b ajax_fallback 31 | git push -u origin ajax_fallback 32 | 33 | To push changes in this branch: 34 | 35 | git push 36 | 37 | If you get an error, pull the latest files, then try again: 38 | 39 | git pull 40 | git push 41 | 42 | If, after that, you still get an error for "git push", pull on master, then 43 | go back to the branch and try again: 44 | 45 | git checkout master 46 | git pull --rebase 47 | 48 | # Try again. 49 | git checkout ajax_fallback 50 | git push 51 | 52 | If, after that, you still get an error and the error message contains 53 | "[rejected]", then find the branch name next to "[rejected]" and update it. 54 | Then go back to the branch and try again. 55 | 56 | git checkout branch_that_was_rejected 57 | git pull 58 | 59 | # Try again. 60 | git checkout ajax_fallback 61 | git push 62 | 63 | To pull changes that other people have made to this branch (do not use rebase!): 64 | 65 | git pull 66 | 67 | To pull changes that have been made to master (do not use rebase!): 68 | 69 | git merge master 70 | git push 71 | 72 | If you get an error for "git push", do a straight "git pull" WITHOUT "--rebase". 73 | 74 | git pull 75 | 76 | To see the full diff of what's changed in this branch: 77 | 78 | git checkout master 79 | git diff master ajax_fallback 80 | 81 | When you're ready to merge the branch back into master: 82 | 83 | # Double check the full diff of what changed. 84 | git checkout master 85 | git diff master ajax_fallback 86 | 87 | # Merge it (keep in mind you're still in master). 88 | git merge ajax_fallback 89 | git push 90 | 91 | # Delete the local and remote branches. 92 | git branch -d ajax_fallback 93 | git push origin :ajax_fallback 94 | 95 | To delete a branch without merging it back into master: 96 | 97 | git checkout master 98 | git branch -D ajax_fallback 99 | git push origin :ajax_fallback 100 | 101 | ################################### 102 | # REMOTE BRANCHES: OTHER PEOPLE'S # 103 | ################################### 104 | 105 | To check out the branch somebody else has created: 106 | 107 | git checkout --track origin/ajax_fallback 108 | 109 | To push changes in this branch: 110 | 111 | git push 112 | 113 | To pull changes that other people have made to this branch (do not use rebase!): 114 | 115 | git pull 116 | 117 | To pull changes that have been made to master (do not use rebase!): 118 | 119 | git merge master 120 | git push 121 | 122 | To see the full diff of what's changed in this branch: 123 | 124 | git checkout master 125 | git diff master ajax_fallback 126 | 127 | ################## 128 | # LOCAL BRANCHES # 129 | ################## 130 | 131 | Generally all of our branches are remote, but if you want to create a local one, 132 | a few things are different -- namely to use "git rebase master" when you pull 133 | changes from master. 134 | 135 | To create the branch: 136 | 137 | git checkout -b ajax_fallback 138 | 139 | To pull changes that have been made to master: 140 | 141 | git rebase master 142 | 143 | ################ 144 | # VIEWING INFO # 145 | ################ 146 | 147 | To view which branch you're on: 148 | 149 | git status 150 | 151 | To view all branches, including remotes: 152 | 153 | git branch -a 154 | 155 | To view all branches, with information about whether they're tracking/remotes: 156 | 157 | git remote show origin 158 | 159 | ################ 160 | # USEFUL LINKS # 161 | ################ 162 | 163 | GitHub Git cheat sheet 164 | http://help.github.com/git-cheat-sheets/ 165 | 166 | Why do we use --rebase when pulling on master? 167 | http://gitready.com/advanced/2009/02/11/pull-with-rebase.html 168 | 169 | Remotes 170 | http://progit.org/book/ch3-5.html 171 | --------------------------------------------------------------------------------