git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] build: add default aliases

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Sep 21, 2013, 19:20 UTC
Message-ID
<1379791221-29925-1-git-send-email-felipe.contreras@gmail.com>
For now simply add a few common aliases.
  co = checkout
  ci = commit
  rb = rebase
  st = status
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---

I still think we should ship a default /etc/gitconfig, but the project needs to agree it's a good change, and nobody every agrees changes are good. So this is the minimal change that achieves the desired result.

 Documentation/git-checkout.txt |  5 +++++
 Documentation/git-commit.txt   |  5 +++++
 Documentation/git-rebase.txt   |  5 +++++
 Documentation/git-status.txt   |  5 +++++
 alias.c                        | 17 +++++++++++++++++
 5 files changed, 37 insertions(+)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index ca118ac..7597813 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -14,6 +14,11 @@ SYNOPSIS
 'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
 'git checkout' [-p|--patch] [<tree-ish>] [--] [<paths>...]
 
+ALIAS
+-----
+
+git co
+
 DESCRIPTION
 -----------
 Updates files in the working tree to match the version in the index
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 1a7616c..8705abc 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -15,6 +15,11 @@ SYNOPSIS
 	   [--date=<date>] [--cleanup=<mode>] [--[no-]status]
 	   [-i | -o] [-S[<keyid>]] [--] [<file>...]
 
+ALIAS
+-----
+
+git ci
+
 DESCRIPTION
 -----------
 Stores the current contents of the index in a new commit along
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 6b2e1c8..bb18fea 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -14,6 +14,11 @@ SYNOPSIS
 	--root [<branch>]
 'git rebase' --continue | --skip | --abort | --edit-todo
 
+ALIAS
+-----
+
+git rb
+
 DESCRIPTION
 -----------
 If <branch> is specified, 'git rebase' will perform an automatic
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 9046df9..30ecd25 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -11,6 +11,11 @@ SYNOPSIS
 [verse]
 'git status' [<options>...] [--] [<pathspec>...]
 
+ALIAS
+-----
+
+git st
+
 DESCRIPTION
 -----------
 Displays paths that have differences between the index file and the
diff --git a/alias.c b/alias.c
index eb9f08b..d6bad69 100644
--- a/alias.c
+++ b/alias.c
@@ -14,11 +14,28 @@ static int alias_lookup_cb(const char *k, const char *v, void *cb)
 	return 0;
 }
 
+static struct {
+	const char *key;
+	const char *val;
+} default_aliases[] = {
+	{ "co", "checkout" },
+	{ "ci", "checkout" },
+	{ "rb", "rebase" },
+	{ "st", "status" },
+};
+
 char *alias_lookup(const char *alias)
 {
+	int i;
 	alias_key = alias;
 	alias_val = NULL;
 	git_config(alias_lookup_cb, NULL);
+	if (alias_val)
+		return alias_val;
+	for (i = 0; i < ARRAY_SIZE(default_aliases); i++) {
+		if (!strcmp(alias, default_aliases[i].key))
+			return xstrdup(default_aliases[i].val);
+	}
 	return alias_val;
 }
 
-- 
1.8.4-fc
Next: Jeff King
Message 1 of 34 in “build: add default aliases”
  1. build: add default aliasesFelipe Contreras, Sep 21, 2013
  2. Jeff KingSep 24, 2013
  3. Felipe ContrerasSep 24, 2013
  4. Jeff KingSep 24, 2013
  5. Felipe ContrerasSep 24, 2013
  6. Jeff KingSep 24, 2013
  7. Felipe ContrerasSep 24, 2013
  8. Jeff KingSep 24, 2013
  9. Felipe ContrerasSep 24, 2013
  10. Jonathan NiederSep 24, 2013
  11. John SzakmeisterSep 24, 2013
  12. Felipe ContrerasSep 28, 2013
  13. Michael HaggertySep 29, 2013
  14. Felipe ContrerasSep 29, 2013
  15. Jonathan NiederSep 30, 2013
  16. Duy NguyenOct 1, 2013
  17. Junio C HamanoOct 15, 2013
  18. Felipe ContrerasOct 16, 2013
  19. Junio C HamanoOct 17, 2013
  20. Felipe ContrerasOct 17, 2013
  21. John SzakmeisterSep 24, 2013
  22. Felipe ContrerasSep 24, 2013
  23. John SzakmeisterSep 24, 2013
  24. Felipe ContrerasSep 24, 2013
  25. John SzakmeisterSep 25, 2013
  26. Felipe ContrerasSep 25, 2013
  27. Matthieu MoySep 25, 2013
  28. Felipe ContrerasSep 25, 2013
  29. Matthieu MoySep 25, 2013
  30. Felipe ContrerasSep 25, 2013
  31. Matthieu MoySep 25, 2013
  32. Felipe ContrerasSep 25, 2013
  33. SZEDER GáborSep 24, 2013
  34. build: add default aliasesFelipe Contreras, Sep 24, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.