{"componentChunkName":"component---src-templates-blog-post-template-js","path":"/2017/06/01/beginner-to-git-aliases/","result":{"data":{"mdx":{"id":"b4981904-af5f-57a8-bdc0-11ed861b5837","frontmatter":{"title":"Moving from beginner to (slightly more) advanced git with aliases.","date":"2017 June 1st","cover":{"id":"b40b3f28-4df5-50ed-95e3-b9ef2f2bce98","publicURL":"/static/cover-282c13fb34ddd270a807323453adc9af.jpg"}},"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"date\": \"2017-06-01T00:00:00.000Z\",\n  \"title\": \"Moving from beginner to (slightly more) advanced git with aliases.\",\n  \"tags\": [\"information\", \"guide\"],\n  \"published\": true,\n  \"cover\": \"./cover.jpg\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"Speed up your git workflow with git aliases, this is a brief\\nintroduction on using aliases \\uD83D\\uDC4C\\uD83D\\uDE80\\uD83D\\uDC4D\"), mdx(\"p\", null, \"The more you work with Git the more familiar you become with the\\ncommands used in your every day workflow for your projects or your\\nteam\\u2019s projects.\"), mdx(\"p\", null, \"Commands like naming and creating feature branches making pull\\nrequests or pushing your changes if you have the requisite\\npermissions.\"), mdx(\"p\", null, \"So still used by me on a daily basis, and everyone else that uses git\\n\", \"[I presume]\", \" is the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git add .\"), \" command, then\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git commit -m 'my awesome feature'\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git push\"), \" or\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git push origin <branch>\")), mdx(\"p\", null, \"In my short time using Git I have always just typed out the full\\ncommands [usually with \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/spences10/cheat-sheets/blob/master/git.md\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"my cheatsheet\"), \" close to hand]\\nand thought nothing more of it, that is how you use the tool, right?\"), mdx(\"p\", null, \"Well that was what I foolishly presumed until I learned about\\ndotfiles, I learned about \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".\"), \" files from listening to the\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://www.toolsday.io/\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"toolsday.io\"), \" podcast with \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://twitter.com/chrisdhanaraj\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Chris\"), \" and \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://twitter.com/una\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Una\"), \" a\\ngreat channel for learning about tooling \\uD83D\\uDC4D the podcast was about \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://www.toolsday.io/episodes/git.html\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Git\\nTools\"), \" give it a listen it\\u2019s a great show.\"), mdx(\"p\", null, \"This was a pretty cool learning experience for me and I now have a\\npretty efficient git workflow \\uD83D\\uDE80\"), mdx(\"p\", null, \"Let\\u2019s go over \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".gitconfig\"), \", do you remember having to enter your email\\naddress and name when first setting up Git on your computer? That\\ninformation is stored in your \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".gitconfig\"), \" file, your file will be\\nlocated in your user folder on Windows\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"C:\\\\Users\\\\yourusername\\\\.gitconfig\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"~/.gitconfig\"), \" on Linux/Mac\"), mdx(\"p\", null, \"If you navigate to the file in the text editor of your choice and pop\\nit open you\\u2019ll see your details under the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"[user]\"), \" flag, here\\u2019s mine:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), \"[user]\\n  name = spences10\\n  email = spences10apps@gmail.com\\n\")), mdx(\"p\", null, \"I\\u2019m not sure what other configuration options you may have in yours so\\nwe\\u2019re just going to concentrate on the aliases, aliases can be used so\\nthat you can shorten the commands \", \"[or make them longer if you like]\", \"\\nbut I\\u2019m all for reducing key strokes, even if it is one or two less.\"), mdx(\"p\", null, \"So let\\u2019s review the common commands I mentioned at the start:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), \"git add .\\ngit commit -m 'my awesome feature'\\ngit push\\n\")), mdx(\"p\", null, \"So with aliases we can shorten these down a bit:\"), mdx(\"p\", null, \"In your \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".gitconfig\"), \" file if there\\u2019s not already one there add in the\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"[aliases]\"), \" section, I have mine above my user details, then add in\\nsome aliases:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), \"[alias]\\n  a = add .\\n  c = commit -am\\n  p = push\\n\\n[user]\\n  name = spences10\\n  email = spences10apps@gmail.com\\n\")), mdx(\"p\", null, \"So now we can shorten down our workflow for adding a change to one of\\nour repos:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), \"git add .\\ngit commit -m 'my awesome feature'\\ngit push\\n\")), mdx(\"p\", null, \"Will become:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), \"git a\\ngit c 'my awesome feature'\\ngit p\\n\")), mdx(\"p\", null, \"It\\u2019s not a massive reduction in what you\\u2019re typing but you\\u2019ll be\\namazed at how quickly you become accustomed to it and start adding\\nmore an more.\"), mdx(\"p\", null, \"Here\\u2019s my current list of aliases:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), \"[alias]\\n  a = add .\\n  b = branch\\n  c = commit -am\\n  cl = clone\\n  co = checkout\\n  d = diff\\n  f = fetch\\n  i = init\\n  o = open # see: https://github.com/paulirish/git-open \\u2665\\n  p = push\\n  pt = push --tags\\n  s = status\\n  t = tag\\n\")), mdx(\"p\", null, \"A new one I have found out whilst making this post is\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"clone --depth 1\"), \" which clones only the HEAD of the repository instead\\nof the whole repository, so say if you were cloning react you\\u2019d just\\nget the master version rather than the other 38 branches included in\\nthe repository. Pretty neat \\uD83D\\uDC4D so that could be aliased into something\\na lot shorter \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git cl1d\"), \"?\"), mdx(\"p\", null, \"You\\u2019ll no doubt notice the link I have in there for \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"o = open\"), \" that\\nlittle gem belongs to \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/paulirish\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Paul Irish\"), \" it\\u2019s an npm package that will\\npop open a browser tab to the current repository you are in, pretty\\nneat right?\"), mdx(\"p\", null, \"I\\u2019m sure there are many, many more ways to configure Git if you take a\\nlook at \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/paulirish/dotfiles/blob/master/.gitconfig\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Paul Irish\"), \"\\u2019s dotfiles repo for his \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".gitconfig\"), \" you\\u2019ll\\nsee there is a lot of ways to configure Git, I\\u2019m still learning and\\nfinding new ways to do things.\"), mdx(\"p\", null, \"If there is anything I have missed, or if you have a better way to dom\\nsomething then please let me know \\uD83D\\uDC4D\"), mdx(\"p\", null, \"Get me on \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://twitter.com/spences10\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Twitter\"), \" or \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/spences10/ama\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Ask Me Anything\"), \" on GitHub\"), mdx(\"p\", null, \"If you like this post or if it has helped you in any way then please\\ngive it a like and don\\u2019t forget to share it on social media \\uD83D\\uDE4C\"));\n}\n;\nMDXContent.isMDXComponent = true;","excerpt":"Speed up your git workflow with git aliases, this is a brief\nintroduction on using aliases 👌🚀👍 The more you work with Git the more…","tableOfContents":{},"timeToRead":2,"fields":{"slug":"/2017/06/01/beginner-to-git-aliases/","editLink":"https://github.com/spences10/thelocalhost.blog/edit/authoring/posts/2017/06/01/beginner-to-git-aliases/index.md"}}},"pageContext":{"slug":"/2017/06/01/beginner-to-git-aliases/","previous":{"id":"b465bae8-287e-5195-9502-3b292471ae8c","excerpt":"No doubt you have heard of Git or GitHub for source control, but\n what is source control? “Revision control (also known as version control, source control or\n(source) code management (SCM)) is the management of multiple\nrevisions of the same unit of…","frontmatter":{"title":"Just starting out with Git and GitHub? It gets easier, honest!","date":"2017-05-31T00:00:00.000Z"},"fields":{"slug":"/2017/05/31/gets-better-with-git/"}},"next":{"id":"0ead006c-347e-5884-ae54-8c2ada5bed30","excerpt":"How to combine two separate unrelated Git repositories into one with\nsingle history timeline. Just adding a quick note on this… I had a project that started off as it’s own project but it ended up\nneeding to go into an already existing project, so I…","frontmatter":{"title":"Git ` — allow-unrelated-histories`","date":"2017-06-30T00:00:00.000Z"},"fields":{"slug":"/2017/06/30/git-allow-unrelated-histories/"}}}}}