Changes between Version 41 and Version 42 of DeveloperGuidelines/Git


Ignore:
Timestamp:
04/12/12 21:35:59 (10 years ago)
Author:
g0wda
Comment:

Inadvertently moved up stuff from alternative workflow I think removed the use of git pull because git fetch and git merge together will help us point out errors better.

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Git

    v41 v42  
    55=== Fork a fresh Branch ===
    66* 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)
    87* Fork the Eden Branch: https://github.com/flavour/eden/fork_select
    98* Use Git to clone this down to your PC:
     9
     10Note: (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]
    1011{{{
    1112cd web2py/applications
     
    1819We 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
    1920{{{
    20 cd <mybranch>
     21cd <mydirectory>
     22
     23# Set github.com/flavour/eden as the upstream repository
     24git remote add upstream git://github.com/flavour/eden.git
     25
    2126# Update your working directory with latest code from Trunk
    22 git pull upstream master
     27git fetch upstream
     28git merge upstream/master
    2329git checkout -b <mystory>
     30
    2431# Write Code
    25 git commit -am "My Story"
     32git commit -am "My Story: Part 1"
     33.
     34.
     35.
     36git commit -am "My Story: Part N"
     37
    2638# Quick review of code (no test code left in, etc)
    27 git diff master
     39git diff master...HEAD
     40
    2841# 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>
     42git fetch upstream
     43git merge upstream/master
     44
    3345# 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>
     46git 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:
     49git stash
     50git reset HEAD@{N}
     51git commit -am 'Your commit message for the one-big-commit'
     52git push upstream HEAD(or your-branch/tag-name)
     53git stash pop
     54
    4155}}}
    4256
    4357Once 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)
    6259
    6360==== Resolving Merge Conflicts ====
     
    113110}}}
    114111
     112=== Resetting to a previous commit ===
     113There are two types of resets soft and hard.
     114A soft reset is done like this:
     115{{{
     116git reset --soft HEAD@{N}
     117}}}
     118This 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
     120A hard reset is done using:
     121{{{
     122git reset --soft HEAD@{N}
     123}}}
     124This resets your branch N previous commits removing both history and changes to the file ever since.
     125 
    115126=== Creating a 2nd branch ===
    116127If you wish to have multiple separate branches to work on, you can run these as separate web2py applications