| | 81 | ==== Resolving Merge Conflicts ==== |
| | 82 | If 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 | }}} |
| | 90 | You can correct these conflict in your code text editor, then add them andcontinue the rebase: |
| | 91 | {{{ |
| | 92 | git add -u |
| | 93 | git rebase --continue |
| | 94 | }}} |
| | 95 | |
| | 96 | You can create the .THIS & .OTHER files using: |
| | 97 | {{{ |
| | 98 | git show :2:file.txt > file.txt.THIS |
| | 99 | git show :3:file.txt > file.txt.OTHER |
| | 100 | }}} |
| | 101 | You can use the changes to a file in the remote branch (theirs / OTHER): |
| | 102 | {{{ |
| | 103 | git checkout --theirs filename.c |
| | 104 | git add filename.c |
| | 105 | git commit |
| | 106 | }}} |
| | 107 | ...or the changes to a file in your local branch (ours / THIS): |
| | 108 | {{{ |
| | 109 | git checkout --ours filename.c |
| | 110 | git add filename.c |
| | 111 | git commit |
| | 112 | }}} |
| | 113 | ...or the changes to ALL files in the remote branch (theirs / OTHER): |
| | 114 | {{{ |
| | 115 | git checkout --theirs . # checkout our local version of all files |
| | 116 | git add -u # mark all conflicted files as merged |
| | 117 | git commit # commit the merge |
| | 118 | }}} |
| | 119 | Or the changes to ALL files in your local branch (ours / THIS) |
| | 120 | {{{ |
| | 121 | git checkout --ours . # checkout our local version of all files |
| | 122 | git add -u # mark all conflicted files as merged |
| | 123 | git commit # commit the merge |
| | 124 | }}} |
| | 125 | 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] |
| | 126 | |
| | 127 | ==== Reverting to last committed code ==== |
| | 128 | If you want to throw away all uncommitted changes (i.e. '{{{bzr revert}}}'), then: |
| | 129 | {{{ |
| | 130 | git reset --hard HEAD |
| | 131 | }}} |
| | 132 | |
| | 133 | === Resetting to a previous commit === |
| | 134 | There are two types of resets soft and hard. |
| | 135 | A soft reset is done like this: |
| | 136 | {{{ |
| | 137 | git reset --soft HEAD@{N} |
| | 138 | }}} |
| | 139 | 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. |
| | 140 | |
| | 141 | A hard reset is done using: |
| | 142 | {{{ |
| | 143 | git reset --soft HEAD@{N} |
| | 144 | }}} |
| | 145 | This resets your branch N previous commits removing both history and changes to the file ever since. |
| | 146 | |
| | 147 | To remove commit from GitHub: |
| | 148 | {{{ |
| | 149 | # Rebase locally (this allows you to remove the last commit) |
| | 150 | git rebase -i HEAD~2 |
| | 151 | # Force update of GitHub |
| | 152 | git push origin +master |
| | 153 | }}} |
| | 154 | |
| 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 | |
| 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 | | |