Skip to main content

add a README for my Git scripts

ID
9ea8252
date
2023-05-01 14:44:29+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
361b977
message
add a README for my Git scripts
changed files
3 files, 106 additions, 67 deletions

Changed files

git/README.md (0) → git/README.md (2942)

diff --git a/git/README.md b/git/README.md
new file mode 100644
index 0000000..1fe7fe5
--- /dev/null
+++ b/git/README.md
@@ -0,0 +1,106 @@
+# git
+
+These scripts are all shortcuts for using [Git], mostly designed to let me do my common Git tasks with as little typing as possible.
+
+[Git]: https://git-scm.com/
+
+## The individual scripts
+
+<dl>
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/bad">
+      <code>bad</code>
+    </a> / <a href="https://github.com/alexwlchan/scripts/blob/main/git/good">
+      <code>good</code>
+    </a>
+  </dt>
+  <dd>
+    alias for <a href="https://git-scm.com/docs/git-bisect"><code>git bisect bad / good</code></a>
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/cleanup_branches">
+      <code>cleanup_branches</code>
+    </a>
+  </dt>
+  <dd>
+    clean up any local branches which have been merged into the primary branch (<code>main</code>, <code>master</code>, etc.)
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gb">
+      <code>gb [name]</code>
+    </a>
+  </dt>
+  <dd>
+    alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout -b [name]</code></a>, which creates a new branch
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gc">
+      <code>gc [name]</code>
+    </a>
+  </dt>
+  <dd>
+    alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout</code></a>, which switches to the given branch
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gcb">
+      <code>gcb</code>
+    </a>
+  </dt>
+  <dd>
+    <strong>g</strong>et the name of the <strong>c</strong>urrent <strong>b</strong>ranch
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gf">
+      <code>gf</code>
+    </a>
+  </dt>
+  <dd>
+    alias for <a href="https://git-scm.com/docs/git-checkout"><code>git fetch origin --prune</code></a>, which gets updated information about all the branches on the remote server
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gitstats">
+      <code>gitstats</code>
+    </a>
+  </dt>
+  <dd>
+    print a brief line count summary of my local Git changes (any staged and uncommitted changes)
+    <p>
+    <pre><code>$ gitstats
++++  0 additions
+--- 57 deletions</code></pre>
+    </p>
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gm">
+      <code>gm</code>
+    </a>
+  </dt>
+  <dd>
+    switch to the primary branch (usually <code>main</code>, hence <code>gm</code>) and pull any changes from the remote server
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gp">
+      <code>gp</code>
+    </a>
+  </dt>
+  <dd>
+    <strong>p</strong>ull any changes on the current branch from the remote server
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/git/gup">
+      <code>gup</code>
+    </a>
+  </dt>
+  <dd>
+    open the current Git repo in <a href="https://gitup.co/">GitUp</a>, my GUI Git client of choice
+  </dd>
+</dl>

git/github-clone (1452) → git/github-clone (0)

diff --git a/git/github-clone b/git/github-clone
deleted file mode 100755
index e3e9af1..0000000
--- a/git/github-clone
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env fish
-# Clone a GitHub repo given its web URL.
-#
-#     $1 = URL of the GitHub page
-#
-# Because switching to the repo homepage, clicking, copying the clone URL,
-# typing 'git clone', pasting, are all more effort than I care to do manually.
-#
-# I use this in combination with a shell alias 'gh-clone', which:
-#
-#   1. Gets the URL of my frontmost browser window
-#   2. Clones the repo with this script
-#   3. Switches to that directory
-#
-
-set url "$argv[1]"
-
-# Get the identifiers for the repository
-set components (string split "/" "$url")
-
-if [ "$components[3]" != "github.com" ]
-    echo "$url is not a GitHub repo"
-    exit 1
-end
-
-set owner $components[4]
-set repo $components[5]
-
-if [ (count $components) -gt 5 ]
-    # Detect if this is a pull request, and divert
-    if [ $components[6] = "pull" ]
-        github-add-pr-branch "$url"
-        exit $status
-    end
-end
-
-set repo_url "git@github.com:$owner/$repo.git"
-
-mkdir -p ~/repos; cd ~/repos
-
-if [ -d $repo ]
-    # If the repo already exists, check we have the selected fork
-    # as a remote.
-    cd $repo
-    git remote -v | grep "$owner" >/dev/null 2>&1
-    if [ $status != 0 ]
-        echo "git remote add $owner $repo_url"
-        git remote add $owner $repo_url
-    end
-    set remote (git remote -v | grep "$owner" | awk '{print $1}')
-    git fetch
-else
-    # Otherwise, clone a fresh copy of the repo
-    echo "git clone $repo_url"
-    git clone $repo_url
-    cd $repo
-end

git/grm (195) → git/grm (0)

diff --git a/git/grm b/git/grm
deleted file mode 100755
index cce3726..0000000
--- a/git/grm
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-# Rebase against the latest version of the primary branch in the origin.
-
-set -o errexit
-set -o nounset
-
-gf
-git stash
-git rebase origin/"$(_get_primary_branch)"
-git stash pop