Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

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/
https://snipt.net/raw/28495c7118fcec2c7287745439f11c6d/
28495c7118fcec2c7287745439f11c6d
bash
Bash
3
2016-12-03T22:07:47
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

List all branches [local + remote]

1
2
3
git branch -a

git branch -r
https://snipt.net/embed/5f6c33daa5010b3521761a243394cfd2/
https://snipt.net/raw/5f6c33daa5010b3521761a243394cfd2/
5f6c33daa5010b3521761a243394cfd2
bash
Bash
3
2016-12-02T23:19:41
True
False
False
Jan 23, 2013 at 07:05 AM
/api/public/snipt/51717/
list-all-branches-local-remote
<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 branch -a </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>git branch -r </span></pre></div> </td></tr></table>
branch, git

Bash

Show latest branch activity in Git

for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
https://snipt.net/embed/b19e52b4fa804023dfd0754e8bfd7f03/
https://snipt.net/raw/b19e52b4fa804023dfd0754e8bfd7f03/
b19e52b4fa804023dfd0754e8bfd7f03
bash
Bash
1
2016-12-04T05:05:07
True
False
False
Oct 26, 2012 at 04:51 AM
/api/public/snipt/49081/
show-latest-branch-activity-in-git
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">for</span> k in <span class="sb">`</span>git branch<span class="p">|</span>perl -pe s/^..//<span class="sb">`</span><span class="p">;</span><span class="k">do</span> <span class="nb">echo</span> -e <span class="sb">`</span>git show --pretty<span class="o">=</span>format:<span class="s2">&quot;%Cgreen%ci %Cblue%cr%Creset&quot;</span> <span class="nv">$k</span><span class="p">|</span>head -n 1<span class="sb">`</span><span class="se">\\</span>t<span class="nv">$k</span><span class="p">;</span><span class="k">done</span><span class="p">|</span>sort -r </span></pre></div> </td></tr></table>
branch, git, show

Bash

Set up a tracked remote branch in Git

git branch --track localBranchName origin/remoteBranchName
https://snipt.net/embed/76738e48604e27515ef03a1538761a81/
https://snipt.net/raw/76738e48604e27515ef03a1538761a81/
76738e48604e27515ef03a1538761a81
bash
Bash
1
2016-12-04T03:09:55
True
False
False
/api/public/snipt/28088/
set-up-a-tracked-remote-branch-in-git
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>git branch --track localBranchName origin/remoteBranchName </span></pre></div> </td></tr></table>
branch, git, versioning

Bash

List all Git branches (local and remote)

git branch -a
https://snipt.net/embed/65636ff7a35976ad1d9263b861f20c57/
https://snipt.net/raw/65636ff7a35976ad1d9263b861f20c57/
65636ff7a35976ad1d9263b861f20c57
bash
Bash
1
2016-12-04T03:09:59
True
False
False
/api/public/snipt/28087/
list-all-git-branches-local-and-remote
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>git branch -a </span></pre></div> </td></tr></table>
branch, git, versioning

Bash

TO PULL A NEW BRANCH FROM A REMOTE REPOSITORY

git fetch origin [remote-branch]:[new-local-branch]
https://snipt.net/embed/bbb4cbc26cbf53d2d6adc9b9e652405a/
https://snipt.net/raw/bbb4cbc26cbf53d2d6adc9b9e652405a/
bbb4cbc26cbf53d2d6adc9b9e652405a
bash
Bash
1
2016-12-03T02:49:41
True
False
False
/api/public/snipt/2000/
to-pull-a-new-branch-from-a-remote-repository
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>git fetch origin <span class="o">[</span>remote-branch<span class="o">]</span>:<span class="o">[</span>new-local-branch<span class="o">]</span> </span></pre></div> </td></tr></table>
branch, checkout, git, remote
Copyrighted, illegal, or inappropriate content? Email [email protected].