Changes between Version 49 and Version 50 of DeveloperGuidelines/Git


Ignore:
Timestamp:
05/18/12 05:28:28 (9 years ago)
Author:
Fran Boon
Comment:

Remove duplicate 'Alternate Workflow'

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Git

    v49 v50  
    7979}}}
    8080
     81==== Resolving Merge Conflicts ====
     82If you encounter conflicts during the rebase, the conflicts will be tagged in the files with:
     83{{{
     84<<<<<<< HEAD
     85# Commits from Trunk
     86=======
     87# Commits from <mystory>
     88>>>>>>> "My Story"
     89}}}
     90You can correct these conflict in your code text editor, then add them andcontinue the rebase:
     91{{{
     92git add -u
     93git rebase --continue
     94}}}
     95
     96You can create the .THIS & .OTHER files using:
     97{{{
     98git show :2:file.txt > file.txt.THIS
     99git show :3:file.txt > file.txt.OTHER
     100}}}
     101You can use the changes to a file in the remote branch (theirs / OTHER):
     102{{{
     103git checkout --theirs filename.c
     104git add filename.c
     105git commit
     106}}}
     107...or the changes to a file in your local branch (ours / THIS):
     108{{{
     109git checkout --ours filename.c
     110git add filename.c
     111git commit
     112}}}
     113...or the changes to ALL files in the remote branch (theirs / OTHER):
     114{{{
     115git checkout --theirs . # checkout our local version of all files
     116git add -u             # mark all conflicted files as merged
     117git commit             # commit the merge
     118}}}
     119Or the changes to ALL files in your local branch (ours / THIS)
     120{{{
     121git checkout --ours . # checkout our local version of all files
     122git add -u            # mark all conflicted files as merged
     123git commit            # commit the merge
     124}}}
     125Although on Windows this seems by default to produce UTF-16 files! ('UCS-2 Little Endian'). A script to make this process easier for Windows users is attached: [http://eden.sahanafoundation.org/attachment/wiki/DeveloperGuidelines/Git/merge.cmd merge.cmd]
     126
     127==== Reverting to last committed code ====
     128If you want to throw away all uncommitted changes (i.e. '{{{bzr revert}}}'), then:
     129{{{
     130git reset --hard HEAD
     131}}}
     132
     133=== Resetting to a previous commit ===
     134There are two types of resets soft and hard.
     135A soft reset is done like this:
     136{{{
     137git reset --soft HEAD@{N}
     138}}}
     139This 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.
     140
     141A hard reset is done using:
     142{{{
     143git reset --soft HEAD@{N}
     144}}}
     145This resets your branch N previous commits removing both history and changes to the file ever since.
     146 
     147To remove commit from GitHub:
     148{{{
     149# Rebase locally (this allows you to remove the last commit)
     150git rebase -i HEAD~2
     151# Force update of GitHub
     152git push origin +master
     153}}}
     154
    81155One more method to squash your commits if they are not in between two executions of git pull or git merge is:
    82156{{{
     
    87161git stash pop
    88162}}}
    89 ==== Resolving Merge Conflicts ====
    90 If you encounter conflicts during the rebase, the conflicts will be tagged in the files with:
    91 {{{
    92 <<<<<<< HEAD
    93 # Commits from Trunk
    94 =======
    95 # Commits from <mystory>
    96 >>>>>>> "My Story"
    97 }}}
    98 You can correct these conflict in your code text editor, then add them andcontinue the rebase:
    99 {{{
    100 git add -u
    101 git rebase --continue
    102 }}}
    103 
    104 You can create the .THIS & .OTHER files using:
    105 {{{
    106 git show :2:file.txt > file.txt.THIS
    107 git show :3:file.txt > file.txt.OTHER
    108 }}}
    109 You can use the changes to a file in the remote branch (theirs / OTHER):
    110 {{{
    111 git checkout --theirs filename.c
    112 git add filename.c
    113 git commit
    114 }}}
    115 ...or the changes to a file in your local branch (ours / THIS):
    116 {{{
    117 git checkout --ours filename.c
    118 git add filename.c
    119 git commit
    120 }}}
    121 ...or the changes to ALL files in the remote branch (theirs / OTHER):
    122 {{{
    123 git checkout --theirs . # checkout our local version of all files
    124 git add -u             # mark all conflicted files as merged
    125 git commit             # commit the merge
    126 }}}
    127 Or the changes to ALL files in your local branch (ours / THIS)
    128 {{{
    129 git checkout --ours . # checkout our local version of all files
    130 git add -u            # mark all conflicted files as merged
    131 git commit            # commit the merge
    132 }}}
    133 Although on Windows this seems by default to produce UTF-16 files! ('UCS-2 Little Endian'). A script to make this process easier for Windows users is attached: [http://eden.sahanafoundation.org/attachment/wiki/DeveloperGuidelines/Git/merge.cmd merge.cmd]
    134 
    135 ==== Reverting to last committed code ====
    136 If you want to throw away all uncommitted changes (i.e. '{{{bzr revert}}}'), then:
    137 {{{
    138 git reset --hard HEAD
    139 }}}
    140 
    141 === Resetting to a previous commit ===
    142 There are two types of resets soft and hard.
    143 A soft reset is done like this:
    144 {{{
    145 git reset --soft HEAD@{N}
    146 }}}
    147 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.
    148 
    149 A hard reset is done using:
    150 {{{
    151 git reset --soft HEAD@{N}
    152 }}}
    153 This resets your branch N previous commits removing both history and changes to the file ever since.
    154  
    155 To remove commit from GitHub:
    156 {{{
    157 # Rebase locally (this allows you to remove the last commit)
    158 git rebase -i HEAD~2
    159 # Force update of GitHub
    160 git push origin +master
    161 }}}
     163
    162164=== Creating a 2nd branch ===
    163165If you wish to have multiple separate branches to work on, you can run these as separate web2py applications
     
    219221* http://blogtrottr.com
    220222
    221 == Alternate Developer Workflow ==
    222 This is an alternate woerkflow which we shoudl deprecate after seeing whether anythign should be moved up
    223  * Make sure your work is fully tested.
    224  * Tell git about any new files you've added. If you've added a new directory, you can just add the files in the directory and git will add the directory too. (Do "git help add" for a description of how to use the bzr add command.)
    225 {{{
    226 git add filename...
    227 }}}
    228  * Commit your changes -- this records them in your local git repository. Provide a message that describes what the change is for. If it fixes a bug, include the ticket number.
    229 {{{
    230 git commit -a -m "Describe your change here."
    231 }}}
    232  * It is really important, that the forked and the main eden repositorys are in sync here as we want to avoid merge-conflicts. To do that we need a branch of the eden master-repository:
    233 {{{
    234  * Make sure that you are in the Eden directory here!
    235 git remote add upstream git://github.com/flavour/eden.git
    236 git fetch upstream
    237 }}}
    238  * Now you have a branch of the original Eden repository. If you want to update your master-branch, you can fetch it again and merge both branches:
    239 {{{
    240 git fetch upstream
    241 git merge upstream/master
    242 }}}
    243  * Solve the conflicts if there were any
    244  * Finally commit the merged version, push it to GitHub and send a Pull-Request on the GitHub site:
    245 {{{
    246 git status
    247 ... add missing files ...
    248 git commit -a -m "Some message"
    249 git push
    250 }}}
    251 
    252223== Resources ==
    253224* Community Book: http://book.git-scm.com