User Tools

Site Tools


git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
git [2023/02/07 16:18] – Document blobless clone dblumegit [2023/06/21 09:22] – [git] dblume
Line 24: Line 24:
   git@fake.github.com:project/project.git   git@fake.github.com:project/project.git
 </code> </code>
 +
 +Eventually, if you want to add another branch to a single-branch clone:
 +
 +  git remote set-branches --add origin another-branch
 +
 +Or to de-single-branch-ize a clone:
 +
 +  git remote set-branches origin "*"
 +
  
 ===== Creating a new remote repository from an existing local one ===== ===== Creating a new remote repository from an existing local one =====
Line 68: Line 77:
   $ git push --set-upstream origin new_branch   $ git push --set-upstream origin new_branch
  
 +==== Creating a local branch from an existing remote ====
 +
 +After doing a fetch, and suppose "origin/remote-branch" exists, then just:
 +
 +  $ git switch remote-branch
 ==== Changing a local branch to a new remote branch ==== ==== Changing a local branch to a new remote branch ====
  
Line 110: Line 124:
 git switch main git switch main
 git branch -d bugfix/JIRA-1-new-bugfix git branch -d bugfix/JIRA-1-new-bugfix
 +git pull
 +</code>
 +
 +====== Resolving a Merge Conflict ======
 +
 +<code>
 +git mergetool (possibly with filename)  # Bring up the vim 3-way diff
 +
 +# +----------+-----------+------------------+
 +# | (others) | (common)  | (my most recent) |
 +# | LOCAL    | BASE      | REMOTE           |
 +# +-----------------------------------------+
 +# |                                         |
 +# | temp file with <<< ||| >>> diffs        |
 +# +-----------------------------------------+
 +
 +git commit -a -m "Resolved merge conflict"
 +</code>
 +
 +Possibly keep rebasing.
 +<code>
 +git rebase --continue
 git pull git pull
 </code> </code>
Line 136: Line 172:
 <code bash> <code bash>
 git pull --rebase  # --dry-run to test first git pull --rebase  # --dry-run to test first
 +</code>
 +
 +====== Applying changes in a stash to a changed file =====
 +
 +When ''git stash apply'' doesn't work: Show the stash changes and pipe that to patch. Now you have a patch you can apply.
 +
 +<code>
 +git stash show -p | patch -p0
 </code> </code>
  
git.txt · Last modified: 2024/04/11 16:58 by dblume