snipt

Ctrl+h for KB shortcuts

Bash

git > checkout a new branch, list all branches, checkout master

1
2
3
$ git checkout -b new-branch-name
$ git branch
$ git checkout master
https://snipt.net/embed/28495c7118fcec2c7287745439f11c6d/
/raw/28495c7118fcec2c7287745439f11c6d/
28495c7118fcec2c7287745439f11c6d
bash
Bash
3
2019-06-14T02:30:56
True
False
False
Mar 09, 2013 at 06:00 AM
/api/public/snipt/55963/
git-checkout-a-new-branch-list-all-branches-checkout-master
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ git checkout -b new-branch-name </span><span id="L-2"><a name="L-2"></a>$ git branch </span><span id="L-3"><a name="L-3"></a>$ git checkout master </span></pre></div> </td></tr></table>
branch, checkout, dvcs, git, repo

Bash

git > add repo to github

$ git remote add origin [email protected]:<username>/repo_name.git
$ git push -u origin master
https://snipt.net/embed/48e1b3c2494e74bfbeb48d8947c96311/
/raw/48e1b3c2494e74bfbeb48d8947c96311/
48e1b3c2494e74bfbeb48d8947c96311
bash
Bash
2
2019-06-12T03:35:27
True
False
False
/api/public/snipt/55962/
git-add-repo-to-github
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ git remote add origin [email protected]:&lt;username&gt;/repo_name.git </span><span id="L-2"><a name="L-2"></a>$ git push -u origin master </span></pre></div> </td></tr></table>
git, github, push, remote, repo

Bash

Add new Git repo on local machine

1
2
3
4
5
6
7
// borrowed from http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/

#On local machine
cd foo_project
git init
git add *
git commit -m "My initial commit message"
https://snipt.net/embed/bef4e291498b234b9e9da35f3170bdf1/
/raw/bef4e291498b234b9e9da35f3170bdf1/
bef4e291498b234b9e9da35f3170bdf1
bash
Bash
7
2019-06-08T17:18:41
True
False
False
/api/public/snipt/36716/
add-new-git-repo-on-local-machine
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>// borrowed from http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/ </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1">#On local machine</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">cd</span> foo_project </span><span id="L-5"><a name="L-5"></a>git init </span><span id="L-6"><a name="L-6"></a>git add * </span><span id="L-7"><a name="L-7"></a>git commit -m <span class="s2">&quot;My initial commit message&quot;</span> </span></pre></div> </td></tr></table>
git, repo