Changes between Version 41 and Version 42 of DeveloperGuidelines/Git
- Timestamp:
- 04/12/12 21:35:59 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Git
v41 v42 5 5 === Fork a fresh Branch === 6 6 * Sign-up for an account on [https://github.com GitHub] 7 * So that you can contribute code back to the project you will need an SSH public key. There is on-line help at github (select Beginner - Set Up Git and then scroll down to Set Up SSH Keys)8 7 * Fork the Eden Branch: https://github.com/flavour/eden/fork_select 9 8 * Use Git to clone this down to your PC: 9 10 Note: (So that you can contribute code back to the project) If you want to use SSH to push your changes to the code back to Github, you will need an SSH public key. There is on-line help at github (select Beginner - Set Up Git and then scroll down to Set Up SSH Keys) [1] 10 11 {{{ 11 12 cd web2py/applications … … 18 19 We suggest adopting the [http://blog.hasmanythrough.com/2008/12/18/agile-git-and-the-story-branch-pattern Story Branch] pattern, which allows squashing commits in order to keep the main Trunk as clean as possible 19 20 {{{ 20 cd <mybranch> 21 cd <mydirectory> 22 23 # Set github.com/flavour/eden as the upstream repository 24 git remote add upstream git://github.com/flavour/eden.git 25 21 26 # Update your working directory with latest code from Trunk 22 git pull upstream master 27 git fetch upstream 28 git merge upstream/master 23 29 git checkout -b <mystory> 30 24 31 # Write Code 25 git commit -am "My Story" 32 git commit -am "My Story: Part 1" 33 . 34 . 35 . 36 git commit -am "My Story: Part N" 37 26 38 # Quick review of code (no test code left in, etc) 27 git diff master 39 git diff master...HEAD 40 28 41 # Merge latest Trunk 29 git checkout master 30 git pull # to get any merges, pulls or edits which you may have done on your GitHub branch 31 git pull upstream master 32 git checkout <mystory> 42 git fetch upstream 43 git merge upstream/master 44 33 45 # Squash commits to as few as possible to keep revision history clean & make it easier to review the work 34 git rebase -i master 35 # Push to your branch on GitHub 36 git checkout master 37 git merge <mystory> 38 git push 39 # Cleanup 40 git branch -d <mystory> 46 git rebase -i 47 48 # One more method to squash your commits if they are not in between two executions of git pull or git merge is: 49 git stash 50 git reset HEAD@{N} 51 git commit -am 'Your commit message for the one-big-commit' 52 git push upstream HEAD(or your-branch/tag-name) 53 git stash pop 54 41 55 }}} 42 56 43 57 Once you have pushed to your branch on GitHub, you will likely want this to be merged with Trunk - this should be done via a Pull Request. This is done on GitHub: 44 * https://github.com/mygitusername/eden/pull/new/master 45 46 ==== Squashing Commits ==== 47 If you didn't squash your commits before submitting the Pull Request, you may be asked to do so so that the pull request contains a single commit which is easy to review & applies cleanly. 48 49 This isn't directly possible once your code is Pushed. 50 51 Option 1: 52 {{{ 53 git stash 54 git checkout -b newbranch 55 # Add an extra tilde per commit to squash (this assumes 2 commits) 56 git reset HEAD~~ 57 git commit -am 'Sqashed!' 58 }}} 59 60 Option2: [[BR]] 61 Create a patch & apply this to a clean clone. 58 * https://github.com/mygitusername/eden/pull/new/<mystory>(the branch name) 62 59 63 60 ==== Resolving Merge Conflicts ==== … … 113 110 }}} 114 111 112 === Resetting to a previous commit === 113 There are two types of resets soft and hard. 114 A soft reset is done like this: 115 {{{ 116 git reset --soft HEAD@{N} 117 }}} 118 This resets your branch N previous commits (to a commit at a distance N from HEAD, the latest commit) but only in terms of git history. Hence your code remains untouched by git in a soft reset. 119 120 A hard reset is done using: 121 {{{ 122 git reset --soft HEAD@{N} 123 }}} 124 This resets your branch N previous commits removing both history and changes to the file ever since. 125 115 126 === Creating a 2nd branch === 116 127 If you wish to have multiple separate branches to work on, you can run these as separate web2py applications