aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorjohannst <johannst@users.noreply.github.com>2021-10-03 12:24:21 +0000
committerjohannst <johannst@users.noreply.github.com>2021-10-03 12:24:21 +0000
commit32a4c0dddc20f75b484ffb4a85c5374215416829 (patch)
tree16b80f10b4b57bfb0d6ade13258c772fb2fe49dc /tools
parent7e48cdeb627a59d267407936097914b92c1eee8d (diff)
downloadnotes-32a4c0dddc20f75b484ffb4a85c5374215416829.tar.gz
notes-32a4c0dddc20f75b484ffb4a85c5374215416829.zip
deploy: d646cf94c0cbe74baef5e5711a3cd3f53afc096d
Diffstat (limited to 'tools')
-rw-r--r--tools/git.html72
1 files changed, 44 insertions, 28 deletions
diff --git a/tools/git.html b/tools/git.html
index a1871cd..a140a9a 100644
--- a/tools/git.html
+++ b/tools/git.html
@@ -166,23 +166,18 @@
remote branches
git branch -vv ................. list branch &amp; annotate with head sha1 &amp;
remote tracking branch
- git branch &lt;bname&gt; ............. create branch with name &lt;bname&gt;
+ git branch &lt;bname&gt; ............. create local branch with name &lt;bname&gt;
+ git branch -d &lt;bname&gt; .......... delete local branch with name &lt;bname&gt;
git checkout &lt;bname&gt; ........... switch to branch with name &lt;bname&gt;
git checkout --track &lt;branch&gt; .. start to locally track a remote branch
- git push -u origin &lt;rbname&gt; .... push branch to origin (or other remote), and
- setup &lt;rbname&gt; as tracking branch
-</code></pre>
-<h2><a class="header" href="#resetting" id="resetting">Resetting</a></h2>
-<pre><code class="language-markdown"> git reset [opt] &lt;ref|commit&gt;
- opt:
- --mixed .................... resets index, but not working tree
- --hard ..................... matches the working tree and index to that
- of the tree being switched to any changes to
- tracked files in the working tree since
- &lt;commit&gt; are lost
- git reset HEAD &lt;file&gt; .......... remove file from staging
- git reset --soft HEAD~1 ........ delete most recent commit but keep work
- git reset --hard HEAD~1 ........ delete most recent commit and delete work
+
+ # Remote
+
+ git push -u origin &lt;rbname&gt; ........ push local branch to origin (or other
+ remote), and setup &lt;rbname&gt; as tracking
+ branch
+ git push origin --delete &lt;rbname&gt; .. delete branch &lt;rbname&gt; from origin (or
+ other remote)
</code></pre>
<h2><a class="header" href="#tags" id="tags">Tags</a></h2>
<pre><code class="language-markdown"> git tag -a &lt;tname&gt; -m &quot;descr&quot; ........ creates an annotated tag (full object
@@ -190,22 +185,31 @@
git tag -l ........................... list available tags
git checkout tag/&lt;tname&gt; ............. checkout specific tag
git checkout tag/&lt;tname&gt; -b &lt;bname&gt; .. checkout specific tag in a new branch
+
+ # Remote
+
+ git push origin --tags .... push local tags to origin (or other remote)
</code></pre>
-<h2><a class="header" href="#diff" id="diff">Diff</a></h2>
-<pre><code class="language-markdown"> git diff HEAD:&lt;fname&gt; origin/HEAD:&lt;fname&gt; ... diff files for different refs
- git diff -U$(wc -l &lt;fname&gt;) &lt;fname&gt; ......... shows complete file with diffs
- instead of usual diff snippets
-</code></pre>
-<h2><a class="header" href="#log" id="log">Log</a></h2>
-<pre><code class="language-markdown"> git log --oneline .... shows log in single line per commit -&gt; alias for
- '--pretty=oneline --abbrev-commit'
- git log --graph ...... text based graph of commit history
- git log --decorate ... decorate log with REFs
-</code></pre>
-<h2><a class="header" href="#file-history" id="file-history">File history</a></h2>
-<pre><code class="language-markdown"> git log -p &lt;file&gt; ......... show commit history + diffs for &lt;file&gt;
+<h2><a class="header" href="#log--commit-history" id="log--commit-history">Log &amp; Commit History</a></h2>
+<pre><code class="language-markdown"> git log --oneline ......... shows log in single line per commit -&gt; alias for
+ '--pretty=oneline --abbrev-commit'
+ git log --graph ........... text based graph of commit history
+ git log --decorate ........ decorate log with REFs
+
+ git log -p &lt;file&gt; ......... show commit history + diffs for &lt;file&gt;
git log --oneline &lt;file&gt; .. show commit history for &lt;file&gt; in compact format
</code></pre>
+<h2><a class="header" href="#diff--commit-info" id="diff--commit-info">Diff &amp; Commit Info</a></h2>
+<pre><code class="language-markdown"> git diff &lt;commit&gt;..&lt;commit&gt; [&lt;file&gt;] .... show changes between two arbitrary
+ commits. If one &lt;commit&gt; is omitted
+ it is if HEAD is specified.
+ git diff -U$(wc -l &lt;file&gt;) &lt;file&gt; ....... shows complete file with diffs
+ instead of usual diff snippets
+ git diff --staged ....................... show diffs of staged files
+
+ git show --stat &lt;commit&gt; ................ show files changed by &lt;commit&gt;
+ git show &lt;commit&gt; [&lt;file&gt;] .............. show diffs for &lt;commit&gt;
+</code></pre>
<h2><a class="header" href="#patching" id="patching">Patching</a></h2>
<pre><code class="language-markdown"> git format-patch &lt;opt&gt; &lt;since&gt;/&lt;revision range&gt;
opt:
@@ -230,6 +234,18 @@
# generate single patch file from a certain commit/ref
git format-patch &lt;COMMIT/REF&gt; --stdout &gt; my-patch.patch
</code></pre>
+<h2><a class="header" href="#resetting" id="resetting">Resetting</a></h2>
+<pre><code class="language-markdown"> git reset [opt] &lt;ref|commit&gt;
+ opt:
+ --mixed .................... resets index, but not working tree
+ --hard ..................... matches the working tree and index to that
+ of the tree being switched to any changes to
+ tracked files in the working tree since
+ &lt;commit&gt; are lost
+ git reset HEAD &lt;file&gt; .......... remove file from staging
+ git reset --soft HEAD~1 ........ delete most recent commit but keep work
+ git reset --hard HEAD~1 ........ delete most recent commit and delete work
+</code></pre>
<h2><a class="header" href="#submodules" id="submodules">Submodules</a></h2>
<pre><code class="language-markdown"> git submodule add &lt;url&gt; [&lt;path&gt;] .......... add new submodule to current project
git clone --recursive &lt;url&gt; ............... clone project and recursively all