|
|
| (12 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| =Routine Git Operations=
| | A curated list that will one day soon become git-awesome: [[Git Resources]] |
|
| |
|
| ==Stop Github Asking for Username and Password==
| | Notes on my most common git operations: [[Git Operations]] |
|
| |
|
| ===Step 1: Set up Github SSH Keys===
| | Using Git to deploy static web content: [[Git Deployment]] |
|
| |
|
| https://help.github.com/articles/generating-ssh-keys
| | Syncing a fork: [[Git/Sync a Fork]] |
|
| |
|
| ===Step 2: Switch Repos from HTTPS to SSH===
| | Deleting a remote branch: [[Git/Delete Remote Branch]] |
|
| |
|
| http://stackoverflow.com/questions/10126381/why-does-github-keep-asking-me-for-repo-credentials
| | Tags: [[Git/Tags]] |
|
| |
|
| <pre>
| | Submodules: [[Git/Submodules]] |
| git remote set-url origin git@github.com:user/repo.git
| |
| </pre>
| |
|
| |
|
| =Scenarios=
| | Notes on teaching git: [[Git/Software Carpentry]] |
|
| |
|
| This section covers some scenarios I often run into, but sometimes forget how to resolve.
| |
|
| |
|
| ==Git Conflicts==
| | [[Category:Git]] |
| | |
| Sometimes, when you try and push your commits with <code>git push</code>, you'll see a message like this:
| |
|
| |
|
| <pre>
| |
| $ git push
| |
| To https://github.com/siluria/transport.git
| |
| Merge branch 'master' of https://github.com/siluria/transport
| |
| ! [rejected] master -> master (fetch first)
| |
| error: failed to push some refs to 'https://github.com/siluria/transport.git'
| |
| hint: Updates were rejected because the remote contains work that you do
| |
| hint: not have locally. This is usually caused by another repository pushing
| |
| hint: to the same ref. You may want to first merge the remote changes (e.g.,
| |
| hint: 'git pull') before pushing again.
| |
| hint: See the 'Note about fast-forwards' in 'git push --help' for details.
| |
| </pre>
| |
|
| |
|
| Then, if you try and pull the latest changes with <code>git pull</code>, you might see a message like this:
| | ===quick ref=== |
|
| |
|
| <pre>
| | the thing we always come here for: |
| $ git pull
| |
| remote: Counting objects: 8, done.
| |
| remote: Compressing objects: 100% (8/8), done.
| |
| remote: Total 8 (delta 0), reused 2 (delta 0)
| |
| Unpacking objects: 100% (8/8), done.
| |
| From https://github.com/siluria/transport
| |
| 153782f..10e0b68 master -> origin/master
| |
| Auto-merging twodomain/SubdomainCatalyst.py
| |
| Auto-merging twodomain/Interface.py
| |
| Auto-merging twodomain/Driver.py
| |
| CONFLICT (content): Merge conflict in twodomain/Driver.py
| |
| Automatic merge failed; fix conflicts and then commit the result.
| |
| </pre>
| |
|
| |
|
| In this case, you can edit the file with the conflict, in this case, <code>Driver.py</code>. You'll see some lines like this:
| | <pre style="white-space: pre-wrap;"> |
| | | git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Ch4zm of Hellmouth'; GIT_AUTHOR_EMAIL='ch4zm.of.hellmouth@gmail.com'; GIT_COMMITTER_NAME='Ch4zm of Hellmouth'; GIT_COMMITTER_EMAIL='ch4zm.of.hellmouth@gmail.com';" HEAD; |
| <pre>
| |
| <<<<<<< HEAD
| |
| old code
| |
| ======= | |
| new code
| |
| >>>>>>> iss53
| |
| </pre> | | </pre> |
|
| |
| Edit this file to merge the code however you decide. Once you do that, you'll run <code>git add</code> on the code with the file, which tells git you have resolved the conflict.
| |
|
| |
| <pre>
| |
| $ git add Driver.py
| |
| </pre>
| |
|
| |
| Then - this is key - you run <code>git commit</code> with NO OTHER ARGUMENTS.
| |
|
| |
| If you try and add arguments, i.e., specifying which file to commit, or adding a commit message, you'll see an error like this:
| |
|
| |
| <pre>
| |
| $ git commit Driver.py -m 'resolving conflict.'
| |
| fatal: cannot do a partial commit during a merge.
| |
| </pre>
| |
|
| |
| Just run <code>git commit</code> with no arguments:
| |
|
| |
| <pre>
| |
| $ git commit
| |
| [master d1d98ed] Merge branch 'master' of https://github.com/siluria/transport
| |
| </pre>
| |
|
| |
| Now you should be able to run <code>git push</code> with no problems:
| |
|
| |
| <pre>
| |
| $ git push
| |
| Counting objects: 23, done.
| |
| Delta compression using up to 8 threads.
| |
| Compressing objects: 100% (12/12), done.
| |
| Writing objects: 100% (12/12), 1.48 KiB | 0 bytes/s, done.
| |
| Total 12 (delta 10), reused 0 (delta 0)
| |
| To https://github.com/siluria/transport.git
| |
| 10e0b68..d1d98ed master -> master
| |
| </pre>
| |
|
| |
| [[Category:Git]]
| |