<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>git Archives - Tech Chronicles</title>
	<atom:link href="http://kostacipo.stream/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://kostacipo.stream/tag/git/</link>
	<description>Ramblings of a Tech Dude</description>
	<lastBuildDate>Tue, 12 Jan 2021 12:59:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://kostacipo.stream/wp-content/uploads/2019/12/cropped-profile-32x32.jpg</url>
	<title>git Archives - Tech Chronicles</title>
	<link>http://kostacipo.stream/tag/git/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Git Commands to Live By &#8211; Beyond Git basics</title>
		<link>http://kostacipo.stream/git-commands-to-live-by-beyond-git-basics/</link>
					<comments>http://kostacipo.stream/git-commands-to-live-by-beyond-git-basics/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 12 Jan 2021 12:59:13 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git commands]]></category>
		<guid isPermaLink="false">http://kostacipo.stream/?p=2006</guid>

					<description><![CDATA[<p>Note:&#160;The linked resources will often mention slightly different, often more concise versions of the commands listed here for newer versions of Git. So if you want the latest and greatest, be sure to give them a look. A quick note on syntax []: Optional content &#60;&#62;: Should be replaced by the actual value when running [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/git-commands-to-live-by-beyond-git-basics/">Git Commands to Live By &#8211; Beyond Git basics</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<blockquote>
<p id="f38d" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km fc cg" data-selectable-paragraph=""><span style="font-size: 10pt;">Note:&nbsp;The linked resources will often mention slightly different, often more concise versions of the commands listed here for newer versions of Git. So if you want the latest and greatest, be sure to give them a look.</span></p>
</blockquote>
<h2 id="ff50" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg" data-selectable-paragraph="">A quick note on syntax</h2>
<ul class="">
<li id="b872" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><code class="jg kn ko kp kq b">[]</code>: Optional content</li>
<li id="10b0" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><code class="jg kn ko kp kq b">&lt;&gt;</code>: Should be replaced by the actual value when running the command</li>
</ul>
</div>
</div>
</section>
<div class="n p gy ma mb mc" role="separator">&nbsp;</div>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 id="e221" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Check Out Remote Branches</h1>
<p id="3789" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">We’re probably all familiar with&nbsp;<code class="jg kn ko kp kq b">git pull</code>&nbsp;to bring our local branches up to speed with their remote counterparts. However, if this is our first time working with the remote branch — i.e., it isn’t being tracked by any branch in our local repository — we first need to set that up.</p>
<p id="1487" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km fc cg" data-selectable-paragraph=""><strong class="jt kr">Note:&nbsp;</strong>It’s a good idea to run&nbsp;<code class="jg kn ko kp kq b">git fetch&nbsp;</code>to make sure we’re working with the most up to date version of&nbsp;<code class="jg kn ko kp kq b">remote</code>.</p>
<ul class="">
<li id="067b" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git checkout [-b &lt;new-local-branch-name&gt;] -t &lt;remote&gt;/&lt;branch&gt;</code></li>
<li id="568c" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git checkout -t origin/my-awesome-feature</code></li>
<li id="102a" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Explanation:</strong>&nbsp;This will pull&nbsp;<code class="jg kn ko kp kq b">origin/my-awesome-feature</code>&nbsp;into a new local branch of the same name and set it up to track&nbsp;<code class="jg kn ko kp kq b">origin/my-awesome-feature</code>.&nbsp;<code class="jg kn ko kp kq b">-b</code>&nbsp;will do the same thing, except that the local branch’s name will be set to the one specified.</li>
</ul>
<h4 id="a5a7" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">Resources</h4>
<ul class="">
<li id="8ce1" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/1783426/4348037" rel="noopener nofollow">“How do I check out a remote Git branch?” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="d201" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Delete Remote Branches</h1>
<p id="78ec" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">Deleting a local branch is as simple as writing&nbsp;<code class="jg kn ko kp kq b">git branch -d &lt;branch&gt;</code>. But a different command is needed to delete remote branches.</p>
<ul class="">
<li id="e72d" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:</strong><code class="jg kn ko kp kq b">git push &lt;remote&gt; -d &lt;branch&gt;</code>&nbsp;or&nbsp;<code class="jg kn ko kp kq b">git push &lt;remote&gt; :&lt;branch&gt;</code></li>
<li id="92c3" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:</strong>&nbsp;<code class="jg kn ko kp kq b">git push origin :my-awesome-feature</code></li>
</ul>
<h4 id="430a" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="7fa4" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/2003515/4348037" rel="noopener nofollow">“How do I delete a Git branch locally and remotely?” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="1ef3" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Change Remote URL</h1>
<p id="7863" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">This is for whenever you need to change the URL&nbsp;<code class="jg kn ko kp kq b">&lt;remote&gt;</code>&nbsp;actually points to. For example, if you change your repository’s name, Git will ask you to do this. Here’s how.</p>
<ul class="">
<li id="ec35" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:</strong>&nbsp;<code class="jg kn ko kp kq b">git remote set-url &lt;remote&gt; &lt;newurl&gt;</code></li>
<li id="35f8" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:</strong>&nbsp;<code class="jg kn ko kp kq b">git remote set-url origin github.com/myusername/my-repo</code></li>
</ul>
<h4 id="189f" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="ccac" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-remote" rel="noopener nofollow">git-remote | Git</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="6a0c" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Stash Individual Files</h1>
<p id="59cf" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph=""><code class="jg kn ko kp kq b">git stash</code>&nbsp;is used frequently to momentarily set aside all<strong class="jt kr">&nbsp;</strong>uncommitted changes and reset the branch to the most recent commit. But what if you only want to stash specific files?</p>
<ul class="">
<li id="2f70" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git stash push -- &lt;filepath(s)&gt;</code></li>
<li id="bce4" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git stash push -- src/index.js README.md</code></li>
</ul>
<h4 id="19d4" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="3431" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/3040833/stash-only-one-file-out-of-multiple-files-that-have-changed-with-git#comment78345399_3040833" rel="noopener nofollow">“Stash only one file out of multiple files that have changed with Git?” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="203c" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Show Content of Most Recent Stash</h1>
<p id="5555" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">This one’s useful if you’d like to view the changes a stash would apply before applying them.</p>
<ul class="">
<li id="fae4" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git stash show -p [stash@{&lt;n&gt;}]</code></li>
<li id="9591" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Explanation:<br />
</strong><code class="jg kn ko kp kq b">-p</code>&nbsp;says that we want to see the actual content of the stash. Omitting it will show only the file names.<br />
<code class="jg kn ko kp kq b"><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-stash#Documentation/git-stash.txt-ltstashgt" rel="noopener nofollow">stash@{&lt;n&gt;}</a></code>&nbsp;allows us to specify a certain stash, denoted by&nbsp;<code class="jg kn ko kp kq b">n</code>&nbsp;(0 being the most recent one).</li>
<li id="452c" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git stash show -p stash@{1}</code></li>
<li id="fae7" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>shows the content of the second latest stash</li>
</ul>
<h4 id="90a6" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="fe22" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/10726185/4348037" rel="noopener nofollow">“See what’s in a stash without applying it” | Stash Overflow</a></li>
<li id="d5e1" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-stash#Documentation/git-stash.txt-ltstashgt" rel="noopener nofollow">git-stash | Git</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="bde6" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Apply a Stash Without Deleting It From the Stash List</h1>
<p id="7f59" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">Speaking of applying stashes,&nbsp;<code class="jg kn ko kp kq b">git stash pop</code>&nbsp;is usually the go-to command for this and, which will apply the first stash on the stash list (viewed with&nbsp;<code class="jg kn ko kp kq b">git stash list</code>). The side effect, though, is that the stash is removed from the list in the process. But if you’d like to keep it, Git has you covered.</p>
<ul class="">
<li id="a3a0" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git stash apply</code></li>
<li id="74ca" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Applies the first stash on the list without removing it</li>
<li id="9672" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Tip:&nbsp;</strong>Just as with&nbsp;<code class="jg kn ko kp kq b">git stash show</code>, you can specify which stash to apply by appending&nbsp;<code class="jg kn ko kp kq b">stash@{&lt;n&gt;}</code></li>
</ul>
<h4 id="e416" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="4f7b" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-stash#Documentation/git-stash.txt-apply--index-q--quietltstashgt" rel="noopener nofollow">git-stash | Git</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="5036" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Check Out File From Another Branch</h1>
<p id="cba5" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph=""><code class="jg kn ko kp kq b">git checkout &lt;branch&gt;</code>&nbsp;is no stranger to most Git users. It does exactly what it says, in that it, well, checks out a specific branch. But if needed, the very same command can also be used to check out a single file.</p>
<ul class="">
<li id="603e" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:</strong>&nbsp;<code class="jg kn ko kp kq b">git checkout &lt;branch&gt; -- &lt;path(s)&gt;</code></li>
<li id="7d7a" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git checkout my-awesome-feature src/lasers.js</code></li>
<li id="1770" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Checks out&nbsp;<code class="jg kn ko kp kq b">src/lasers.js</code>&nbsp;from&nbsp;<code class="jg kn ko kp kq b">my-awesome-feature</code></li>
<li id="a7bc" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Tip:&nbsp;</strong>You may also be familiar with&nbsp;<code class="jg kn ko kp kq b">git checkout &lt;commit&gt;</code>. This variant can be used in the same way to check out a file from a specific commit rather than a specific branch.</li>
</ul>
<h4 id="bf43" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="60d8" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/" rel="noopener nofollow">“Git tip: How to ‘merge’ specific files from another branch</a>”</li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="df30" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Work With Multiple Branches Simultaneously</h1>
<p id="e81b" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">If you find yourself often having to checkout a specific branch, for example to use as a reference while working on another branch,&nbsp;<code class="jg kn ko kp kq b">git worktree</code>&nbsp;offers a better alternative.</p>
<ul class="">
<li id="9245" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git worktree add &lt;path&gt; &lt;branch&gt;</code><br />
And when you no longer need it, run:<br />
<code class="jg kn ko kp kq b">git worktree remove [-f] &lt;path&gt;</code></li>
<li id="58cb" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:<br />
</strong>1.<code class="jg kn ko kp kq b">git worktree add my-other-awesome-feature ../my-other-awesome-feature</code><br />
2.&nbsp;<code class="jg kn ko kp kq b">git worktree remove ../my-other-awesome-feature</code></li>
<li id="93e4" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Explanation:&nbsp;</strong>Creates a&nbsp;<a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-worktree#_description" rel="noopener nofollow">linked working tree</a>&nbsp;(i.e., another directory on the file system associated with the repo) called&nbsp;<code class="jg kn ko kp kq b">my-other-awesome-feature</code>, one level above your current working directory, with the specified branch checked out.<br />
You could then, for example, open this directory in another code editor instance or open individual files from it in the current instance.<br />
Once you’re done with the linked working tree, removing it with<br />
<code class="jg kn ko kp kq b">-f</code>&nbsp;will force-remove working trees with uncommitted changes.</li>
</ul>
<h4 id="70ef" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="bd87" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/30186843/4348037" rel="noopener nofollow">“git working on two branches simultaneously” | Stack Overflow</a></li>
<li id="994f" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-worktree" rel="noopener nofollow">git-worktree | Git</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="80a5" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Show Commit Content</h1>
<p id="1b14" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">Somewhat similar to&nbsp;<code class="jg kn ko kp kq b">git stash show</code>, it’s often useful to see the changes introduced by a specific commit.</p>
<ul class="">
<li id="5d38" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:</strong>&nbsp;<code class="jg kn ko kp kq b">git show &lt;commit&gt;</code><br />
Alternatively, to see the changes between two specific commits run<br />
<code class="jg kn ko kp kq b">git diff &lt;commit-a&gt; &lt;commit-b&gt;</code></li>
<li id="898b" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git diff HEAD~ HEAD</code></li>
<li id="feee" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Shows the difference between&nbsp;<code class="jg kn ko kp kq b">HEAD</code>&nbsp;and its immediate ancestor, which is equivalent to&nbsp;<code class="jg kn ko kp kq b">git show</code></li>
</ul>
<h4 id="43ed" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="06e3" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/17563726/how-to-see-the-changes-in-a-git-commit/" rel="noopener nofollow">“How to see the changes in a Git commit?” | Stack Overflow</a></li>
<li id="ce97" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://github.blog/2020-12-17-commits-are-snapshots-not-diffs" rel="noopener nofollow">“Commits are snapshots, not diffs” | The GitHub Blog</a></li>
<li id="2dc2" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/docs/git-log" rel="noopener nofollow">git-log | Git</a></li>
<li id="39de" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History" rel="noopener nofollow">“Git Basics — Viewing the Commit History” | Git</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="e2ef" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Compare Files Between Branches/Commits</h1>
<p id="d87f" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">The power of&nbsp;<code class="jg kn ko kp kq b">git diff</code>&nbsp;isn’t just exclusive to whole commits, as we just saw, but can be used to target individual files.</p>
<ul class="">
<li id="f21c" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git diff &lt;commit-a&gt; &lt;commit-b&gt; -- &lt;path(s)&gt;</code></li>
<li id="dffa" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git diff 0659bdc e6c7c0d -- src/flair.py</code></li>
<li id="68b4" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Shows how the file at one commit differs from the other.<br />
Branch names can also be used here instead of commits to compare the file across branches.</li>
<li id="2559" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Tip:&nbsp;</strong>To compare different files, use<br />
<code class="jg kn ko kp kq b">git diff &lt;commit-a&gt;:&lt;path-a&gt; &lt;commit-b&gt;:&lt;path-b&gt;</code></li>
</ul>
<h4 id="c2d9" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="0e0f" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/4099742/how-to-compare-files-from-two-different-branches" rel="noopener nofollow">“How to compare files from two different branches?” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="691a" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Reset a Single File to Most Recent Commit</h1>
<p id="c5c8" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph=""><code class="jg kn ko kp kq b">git reset --hard</code>&nbsp;is a godsend when you need to go back to the last stable state, for example after some unwanted or unintended changes, but it affects the whole working tree. The command to achieve the same effect but localized to a file should come as no stranger, though.</p>
<ul class="">
<li id="685a" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git checkout [&lt;commit&gt;] -- &lt;path(s)&gt;</code></li>
<li id="5839" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:&nbsp;</strong><code class="jg kn ko kp kq b">git checkout -- README.md</code></li>
<li id="83dc" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>This will reset&nbsp;<code class="jg kn ko kp kq b">README.md</code>&nbsp;to the version in the most recent commit (or a specific commit if one is specified)</li>
</ul>
<h4 id="089e" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="606a" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/7147270/hard-reset-of-a-single-file" rel="noopener nofollow">“Hard reset of a single file” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="a59f" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Change Last Commit Message</h1>
<p id="36c0" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">Ever committed changes only to later want to edit the commit message?</p>
<ul class="">
<li id="dcbd" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git commit --amend [-m '&lt;message&gt;']</code><br />
If the old commit had already been pushed, you’ll need to additionally run<br />
<code class="jg kn ko kp kq b">git push --force-with-lease &lt;remote&gt; &lt;branch&gt;</code>.<code class="jg kn ko kp kq b"><br />
</code><strong class="jt kr">Note:&nbsp;</strong>As a general rule, and especially if you’re working with others, it’s important to be careful when making any changes to already pushed commits.</li>
<li id="4899" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Adds any staged changes to the last commit. If a message is included with the&nbsp;<code class="jg kn ko kp kq b">-m</code>&nbsp;option, the last commit’s message is replaced. Otherwise, this opens the editor at the last commit message.</li>
<li id="9e37" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Tip:&nbsp;</strong>As you can probably already tell,&nbsp;<code class="jg kn ko kp kq b">git commit --amend</code>&nbsp;can be used to change more than just the commit’s message. For example, making changes and committing them with the&nbsp;<code class="jg kn ko kp kq b">--amend</code>&nbsp;option will cause these changes to be added to the last commit rather than creating a new one.</li>
</ul>
<h4 id="58cc" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="4ebd" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/15772171/4348037" rel="noopener nofollow">git-commit | Git</a></li>
<li id="622e" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/8981216/4348037" rel="noopener nofollow">“Changing git commit message after push (given that no one pulled from remote)” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="8065" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Change a Specific Commit Message</h1>
<p id="ab85" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">What about changing a specific<strong class="jt kr">&nbsp;</strong>commit message?</p>
<ul class="">
<li id="ee08" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git rebase -i &lt;commit&gt;</code></li>
<li id="9010" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example (see demo below):&nbsp;</strong><code class="jg kn ko kp kq b">git rebase -i HEAD~3</code></li>
<li id="c39b" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Opens an editor listing commits, starting from the one specified up to the current one. In the example above, this list will be made up of the last three commits.<br />
Replacing&nbsp;<code class="jg kn ko kp kq b">pick</code>&nbsp;with&nbsp;<code class="jg kn ko kp kq b">reword</code>&nbsp;for those commits where you wish to change the message and saving will allow you to do just that.<br />
<strong class="jt kr">Note:&nbsp;</strong>The actual changes are made in the next step. Changing the messages at this point will have no effect!</li>
</ul>
</div>
</div>
<div class="iw">&nbsp;</div>
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h4 id="d1d6" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">Resources</h4>
<ul class="">
<li id="a846" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/1884474/change-old-commit-message-on-git" rel="noopener nofollow">“Change old commit message on Git” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="708c" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Delete Last Commit but Keep the Changes</h1>
<p id="e4de" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">You’ve committed changes that you’d like to keep, but for whatever reason, you don’t want the commit itself. Fret not!</p>
<ul class="">
<li id="631f" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git reset HEAD^<br />
</code><strong class="jt kr">Note:&nbsp;</strong>The warning about making changes to already pushed commits holds here too!</li>
<li id="273a" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Moves&nbsp;<code class="jg kn ko kp kq b">HEAD</code>&nbsp;to point to the previous commit without making any file changes, effectively removing the current commit</li>
<li id="898d" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Tip:&nbsp;</strong>An alternative to this approach is to wait till you’re ready for your next commit and instead of doing so with the usual&nbsp;<code class="jg kn ko kp kq b">git commit</code>, using our old friend&nbsp;<code class="jg kn ko kp kq b">git commit --amend</code>. This will have the same intended effect.</li>
</ul>
<h4 id="3e4a" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="947b" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/a/15772171/4348037" rel="noopener nofollow">“Can I delete a git commit but keep the changes?” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="07ff" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Unstage a File</h1>
<p id="071d" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">What’s the opposite of&nbsp;<code class="jg kn ko kp kq b">git add</code>? I’ll give you a hint. It’s not&nbsp;<code class="jg kn ko kp kq b">git remove</code>.</p>
<ul class="">
<li id="5927" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git reset HEAD &lt;path&gt;</code></li>
<li id="4e18" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>Removes the given file from the index. This is useful for when you’re preparing your next commit and decide a file you’d previously staged with&nbsp;<code class="jg kn ko kp kq b">git add</code>&nbsp;should no longer be part of it. This&nbsp;<em class="ni">doesn’t</em>&nbsp;affect the file itself. So you don’t have to worry about breaking anything.</li>
</ul>
<h4 id="d657" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources:</h4>
<ul class="">
<li id="f41c" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://docs.gitlab.com/ee/university/training/topics/unstage.html" rel="noopener nofollow">Unstage | GitLab</a></li>
<li id="64c3" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified" rel="noopener nofollow">“Git Tools — Reset Demystified” | Git</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="9807" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Remove Ignored Files From Remote</h1>
<p id="f04a" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">If you’ve pushed files and later decided to&nbsp;<code class="jg kn ko kp kq b">.gitignore</code>&nbsp;them, the files will nevertheless persist in your remote repository. To remedy this,&nbsp;<code class="jg kn ko kp kq b">git rm</code>&nbsp;is the tool for the job.</p>
<ul class="">
<li id="f742" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">git rm [-r] [-n] --cached &lt;path(s)&gt;</code>.<br />
Then, simply&nbsp;<code class="jg kn ko kp kq b">add</code>,&nbsp;<code class="jg kn ko kp kq b">commit</code>, and&nbsp;<code class="jg kn ko kp kq b">push</code>.</li>
<li id="3260" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Explanation:</strong><br />
<code class="jg kn ko kp kq b">--cached</code>&nbsp;ensures the files remain in the working tree.<br />
<code class="jg kn ko kp kq b">-n</code>&nbsp;performs a dry run, essentially a sanity check that allows you to first see which files will be affected before actually executing the command. If you’re happy with the results, simply run the command again without it.<br />
<code class="jg kn ko kp kq b">-r</code>&nbsp;is used in case folders are being removed to allow for recursive removal.</li>
<li id="a25b" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example:<br />
</strong>(1)&nbsp;<code class="jg kn ko kp kq b">git rm -r -n --cached .</code>&nbsp;(check files affected)<br />
(2)&nbsp;<code class="jg kn ko kp kq b">git rm -r --cached .</code><br />
(3)&nbsp;<code class="jg kn ko kp kq b">git add .</code><br />
(4)&nbsp;<code class="jg kn ko kp kq b">git commit -m "Remove ignored files"</code><br />
(5)&nbsp;<code class="jg kn ko kp kq b">git push</code></li>
<li id="5380" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:&nbsp;</strong>This is an aggressive but useful form of the command. The result is that your repo will be purged of any files contained in your&nbsp;<code class="jg kn ko kp kq b">.gitignore</code>&nbsp;without you having to explicitly list every single one.</li>
</ul>
<h4 id="6aa0" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="0443" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore" rel="noopener nofollow">“How to make Git ‘forget’ about a file that was tracked but is now in .gitignore?” | Stack Overflow</a></li>
<li id="bb72" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://www.codeblocq.com/2016/01/Untrack-files-already-added-to-git-repository-based-on-gitignore" rel="noopener nofollow">“Untrack files already added to git repository based on .gitignore” | CodeBlocQ</a></li>
<li id="292b" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://stackoverflow.com/questions/5798930/git-rm-cached-x-vs-git-reset-head-x" rel="noopener nofollow">“‘git rm &#8211;cached x’ vs ‘git reset head &#8212; x’?” | Stack Overflow</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 data-selectable-paragraph="">&nbsp;</h1>
<h1 id="c0f6" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Create GitHub Releases</h1>
<p id="68d7" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">Finally, this one’s not strictly a Git command per se but one offered by the GitHub CLI. So you’ll first have to <a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://cli.github.com/" rel="noopener nofollow">download</a>&nbsp;it if you haven’t already.</p>
<ul class="">
<li id="16d1" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Command:&nbsp;</strong><code class="jg kn ko kp kq b">gh release create &lt;version&gt;</code></li>
<li id="7972" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Example (see demo below):&nbsp;</strong><code class="jg kn ko kp kq b">gh release create v0.3</code></li>
<li id="789c" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Effect:</strong>&nbsp;This will open up an interactive command-line menu guiding you through the process of creating your release. The result will be a GitHub release created from the provided version&nbsp;<a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://git-scm.com/book/en/v2/Git-Basics-Tagging" rel="noopener nofollow">tag</a>&nbsp;(a new tag will be created if no such tag exists in your repo).</li>
</ul>
</div>
</div>
<div class="iw">&nbsp;</div>
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<ul class="">
<li id="e419" class="jr js fk jt b gi ju jv jw gl jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ls lt lu cg" data-selectable-paragraph=""><strong class="jt kr">Tip:&nbsp;</strong>At the&nbsp;<code class="jg kn ko kp kq b">Release notes</code><em class="ni">&nbsp;</em>prompt<em class="ni">,&nbsp;</em>choose&nbsp;<code class="jg kn ko kp kq b">Write using commit log as template</code>&nbsp;to have a nice starting point for meaningful release notes. It’s a good idea to run&nbsp;<code class="jg kn ko kp kq b">git fetch --all --tags</code>&nbsp;beforehand to ensure that only commits since the last tag are included in the template.<br />
If an editor other than your default is opened, use&nbsp;<code class="jg kn ko kp kq b">gh config set editor &lt;editor&gt;</code>&nbsp;to set it to one of your choosing — e.g.,&nbsp;<code class="jg kn ko kp kq b">gh config set editor nano</code>.</li>
</ul>
<h4 id="de5b" class="ks kt fk au ku kv kw gk kx ky kz gn la go lb gq lc gr ld gt le gu lf gw lg lh cg">
Resources</h4>
<ul class="">
<li id="44fb" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://cli.github.com/manual/gh_release_create" rel="noopener nofollow">gh release create | GitHub CLI</a></li>
<li id="cd65" class="jr js fk jt b gi lv jv jw gl lw jy jz ka lx kc kd ke ly kg kh ki lz kk kl km ls lt lu cg" data-selectable-paragraph=""><a class="cm jq md-opjjpmhoiojifppkkcdabiobhakljdgm_doc" href="https://cli.github.com/manual/gh_config_set" rel="noopener nofollow">gh config set | GitHub CLI</a></li>
</ul>
</div>
</div>
</section>
<section class="fc fd fe ff fg">
<div class="n p">
<div class="ab ac ae af ag fh ai aj">
<h1 id="98ee" class="mh kt fk au ku mi mj jv kx mk ml jy la mm mn mo lc mp mq mr le ms mt mu lg mv cg" data-selectable-paragraph="">Conclusion</h1>
<p id="1b0d" class="jr js fk jt b gi ln jv jw gl lo jy jz ka lp kc kd ke lq kg kh ki lr kk kl km fc cg" data-selectable-paragraph="">How many of these commands did you know off the top of your head, and what are some other lesser-known yet powerful commands that you use?</p>
</div>
</div>
</section>
<p>The post <a href="http://kostacipo.stream/git-commands-to-live-by-beyond-git-basics/">Git Commands to Live By &#8211; Beyond Git basics</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/git-commands-to-live-by-beyond-git-basics/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>New Gitjacker tool lets you find .git folders exposed online</title>
		<link>http://kostacipo.stream/new-gitjacker-tool-lets-you-find-git-folders-exposed-online/</link>
					<comments>http://kostacipo.stream/new-gitjacker-tool-lets-you-find-git-folders-exposed-online/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 27 Oct 2020 19:42:00 +0000</pubDate>
				<category><![CDATA[Cybersecurity]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[tools]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1829</guid>

					<description><![CDATA[<p>The Tool can also download your Git repositories, allowing attackers to retrieve sensitive configuration files and source code. A new tool called Gitjacker can help developers discover when they’ve accidentally uploaded /.git folders online and have left sensitive information exposed to attackers. Gitjacker was created by British software engineer&#160;Liam Galvin, is written in Go, and [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/new-gitjacker-tool-lets-you-find-git-folders-exposed-online/">New Gitjacker tool lets you find .git folders exposed online</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>The Tool can also download your Git repositories, allowing attackers to retrieve sensitive configuration files and source code.</strong></p>
<div class="row">
<div class="col-12">
<p>A new tool called Gitjacker can help developers discover when they’ve accidentally uploaded /.git folders online and have left sensitive information exposed to attackers.</p>
<div class="relatedContent alignRight">
<p>Gitjacker was created by British software engineer&nbsp;<a href="https://twitter.com/liam_galvin" target="_blank" rel="noopener noreferrer" data-component="externalLink">Liam Galvin</a>, is written in Go, and was released as a free download last month&nbsp;<a href="https://github.com/liamg/gitjacker" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">on GitHub</a>.</p>
<p>In its simplest form, the tool lets users scan a domain and identify the location of a /.git folder on their production systems.</p>
<p>/.git folders should never be uploaded online.</p>
<p>“A .git directory stores all of your [Git] repository data, such as configuration, commit history, and actual content of each file in the repository,” Galvin said in a&nbsp;<a href="https://www.liam-galvin.co.uk/security/2020/09/26/leaking-git-repos-from-misconfigured-sites.html" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">blog post</a>&nbsp;last month when he launched Gitjacker.</p>
<p>“If you can retrieve the full contents of a .git directory for a given website, you will be able to access raw source code for that site, and often juicy configuration data like database passwords, password salts, and more,” he added.</p>
<p>All developers know this; however, accidents happen.</p>
<p>For example, developers working on a website or a web app can accidentally copy their entire Git repository online, including the /.git folder, and forget to remove it. Furthermore, /.git folders can also be included in automated build chains and added to Docker containers that are later installed as web servers.</p>
<p><strong>GITJACKER NOT ONLY FINDS /.GIT FOLDERS BUT IT CAN ALSO FETCH THEIR CONTENT</strong></p>
<p>Attackers can scan the internet for these types of folders, identify accidentally exposed systems, download their content, and gain access to sensitive configuration data or even to an app’s source code.</p>
<p>“Webservers with directory listings enabled make this kind of attack especially easy, as it’s simply a matter of recursively downloading every file in the .git directory and running the following to pull files from the stored object files: <strong><em>git checkout — .</em></strong>“, Galvin said.</p>
<p>“The attack is still possible when directory listings are disabled, but it’s often difficult to retrieve a complete repository in such cases,” Galvin added.</p>
<p>However, this is where Gitjacker comes in. Galvin said he developed Gitjacker to handle the download and extraction of a git repository for users, even in cases where web directory listings are disabled.</p>
<p>Galvin said he developed the tool to be used in penetration tests, but due to its capabilities, Gitjacker will most likely be abused by threat actors as well (<em>as threat actors have a long history of&nbsp;</em><a href="https://www.zdnet.com/article/malware-gangs-love-open-source-offensive-hacking-tools/" target="_blank" rel="noopener noreferrer"><em>abusing open source tools for their operations</em></a>).</p>
<p>And why not? Gitjacker’s capabilities allow attackers to retrieve sensitive configuration files with a few keyboard strokes.</p>
<p>In addition, there’s an incentive for attackers to look for /.git folders. Even after years of warnings [<a href="https://pentester.land/tutorials/2018/10/25/source-code-disclosure-via-exposed-git-folder.html" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">1</a>,&nbsp;<a href="https://dev.to/seds/finding-exposed-git-repositories-49bj" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">2</a>,&nbsp;<a href="https://medium.com/dev-genius/source-code-disclosure-via-exposed-git-folder-24993c7561f1" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">3</a>,&nbsp;<a href="https://medium.com/swlh/hacking-git-directories-e0e60fa79a36" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">4</a>], /.git exposure is still in high numbers, meaning attackers will have an easy time finding domains with /.git folders left exposed online.</p>
<p>For example, in 2018, a Czech developer scanned more than 230 million sites and found that <a href="https://smitka.me/open-git/" target="_blank" rel="noopener noreferrer nofollow" data-component="externalLink">390,000 were exposing /.git folders</a>, but <span style="color: #ff0000;"><strong>only 150,000 of these were fixed</strong></span>.</p>
</div>
</div>
</div>
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div>
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="second-place clear">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="post__block post__block_lead-text" data-v-a249f5ee="">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">
<header class="storyHeader article">
<div class="topContent container">
<div class="row">
<div class="row">
<div class="col-12">&nbsp;</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
</div>
</header>
</div>
</div>
</div>
</div>
<p>The post <a href="http://kostacipo.stream/new-gitjacker-tool-lets-you-find-git-folders-exposed-online/">New Gitjacker tool lets you find .git folders exposed online</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/new-gitjacker-tool-lets-you-find-git-folders-exposed-online/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>10 Useful Git Commands You Should Know</title>
		<link>http://kostacipo.stream/turn-your-commute-into-a-learning-experience/</link>
					<comments>http://kostacipo.stream/turn-your-commute-into-a-learning-experience/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Wed, 23 Jan 2019 05:12:50 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[source control]]></category>
		<guid isPermaLink="false">https://demo.mekshq.com/johannes/dc/?p=103</guid>

					<description><![CDATA[<p>&#160; &#8230; and how to get started with open source development Git is a distributed version control system. It is used for keeping track of projects and files as developers change the code. Git stores information about the project’s progress in a repository. A repository has commits to the project or a set of references [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/turn-your-commute-into-a-learning-experience/">10 Useful Git Commands You Should Know</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>

<h4 class="aq ef gc gd av">&#8230; and how to get started with open source development</h4>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<p id="96b4" class="ix iy cn ar iz b ja jb jc jd je jf jg jh ji jj jk" data-selectable-paragraph="">Git is a distributed version control system. It is used for keeping track of projects and files as developers change the code. Git stores information about the project’s progress in a repository. A repository has commits to the project or a set of references to the commits called heads.</p>
<p id="b901" class="ix iy cn ar iz b ja jb jc jd je jf jg jh ji jj jk" data-selectable-paragraph="">There are a ton of resources on the internet to learn Git from. But for a beginner, it might get intimidating to go through so much of information. So in this article I will briefly go through 10 important git commands to help you get started with git and github.</p>
<h1 id="f7dc" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">1. init</h1>
<h2 id="bd50" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To initialize a git repository for a new or existing project.</h2>
<p id="0a9c" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git init command is used for creating a new git repository. It can be used to convert an existing project to a git repository or initialize a new and empty repository.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="2c9b" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git init [repository name]</span></pre>
<h1 id="5d55" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">2. add</h1>
<h2 id="31d5" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To add changes to index in your working directory.</h2>
<p id="f4ff" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git add command adds a change in the working directory to the staging area. It tells git that you want to include updates to a particular file in the next commit.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="3cb2" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git add [file]</span></pre>
<h1 id="2724" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">3. commit</h1>
<h2 id="64cb" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To commit your changes and sets it to new commit object for your remote version.</h2>
<p id="0027" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git commit command captures a snapshot of the project&#8217;s currently staged changes.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="0ad5" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git commit -m ”commit-message”</span></pre>
<h1 id="b5c5" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">4. stash</h1>
<h2 id="a730" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph=""><strong class="bu">To save changes that you don’t want to commit immediately.</strong></h2>
<p id="5858" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">Use git stash command is used to record the current state of the working directory and the index. This command saves your local modifications away and reverts the working directory to match the head commit.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="e83e" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git stash [list]</span></pre>
<h1 id="8282" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">5. push</h1>
<h2 id="0745" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To push the local changes to the master branch of the project.</h2>
<p id="7daf" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git push command is used to upload local repository content to a remote repository.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="ec47" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git push [branch-name]</span></pre>
<h1 id="1d62" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">6. branch</h1>
<h2 id="c9ef" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To list out all the branches in the project.</h2>
<p id="77f6" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git branch command lets you create, list, rename, and delete branches. However it doesn’t let you switch between branches or put a forked history back together again.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="ec15" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git branch [branch-name]</span></pre>
<h1 id="204c" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">7. checkout</h1>
<h2 id="0b90" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To switch to a different branch.</h2>
<p id="7d7b" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git checkout command lets you navigate between the branches created by git branch. Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells git to record all new commits on that branch.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="a0c4" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git checkout [branch-name]</span></pre>
<h1 id="06cf" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">8. merge</h1>
<h2 id="635a" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To merge two branches you were working on.</h2>
<p id="e0c7" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git merge command is used to integrate changes from another branch. It combines all the integrated changes into a single commit, instead of preserving them as individual commits.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="bdb0" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git merge [branch-name]</span></pre>
<h1 id="96fe" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">9. clone</h1>
<h2 id="5e8f" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To copy a git repository from a remote source.</h2>
<p id="aaa9" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git clone command copies an existing git repository. This is similar to SVN checkout, except the working copy is a git repository, having its own history, manages its own files, and is a completely isolated environment from the original repository.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="0f74" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git clone [url]</span></pre>
<h1 id="be41" class="jl jm cn ar aq jn jo jp jq jr js jt ju jv jw jx jy" data-selectable-paragraph="">10. status</h1>
<h2 id="2f0b" class="jz jm cn ar aq jn ka kb kc kd ke kf kg kh ki kj kk" data-selectable-paragraph="">To check the status of files you’ve changed in your working directory</h2>
<p id="cf04" class="ix iy cn ar iz b ja kl jc km je kn jg ko ji kp jk" data-selectable-paragraph="">The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by git at the moment.</p>
<pre class="ho hp hq hr hs kq kr du"><span id="ecd9" class="jz jm cn ar ks b bj kt ku r kv" data-selectable-paragraph="">git status</span></pre>
</div>
</div>
</section>
<hr class="kw ef kx bg ky ij kz la lb lc ld" />
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h1 id="5ca8" class="jl jm cn ar aq jn jo le jq lf js lg ju lh jw li jy" data-selectable-paragraph="">References/Further Readings</h1>
<div class="lj lk ll lm ln lo">
<section class="lr eu ev ak dc n ap ls lt lu lv lw lx ly lz ma mb mc md me mf mg">
<div class="mh n ex p mi mj">
<div class="bd lp bc gp lq gr">Git &#8211; git-status Documentation</div>
<div class="ml r">
<div class="bd lp bc gp lq gr">s &#8211;short Give the output in the short-format. -b &#8211;branch Show the branch and tracking info even in short-format…</div>
</div>
<div class="mm r">
<div class="bd lp bc gp lq gr">git-scm.com</div>
</div>
</div>
</section>
</div>
<div class="lj lk ll lm ln lo">
<section class="lr eu ev ak dc n ap ls lt lu lv lw lx ly lz ma mb mc md me mf mg">
<div class="mh n ex p mi mj">
<div class="bd lp bc gp lq gr">Top 20 Git Commands With Examples &#8211; DZone Open Source</div>
<div class="ml r">
<div class="bd lp bc gp lq gr">In the previous blog, you got an understanding of what git is. In this blog, I will talk about the Top 20 Git Commands…</div>
</div>
<div class="mm r">
<div class="bd lp bc gp lq gr">dzone.com</div>
</div>
</div>
<div class="mn r">
<div class="sg r mp mq mr mn ms mt mu"> </div>
</div>
</section>
</div>
<div class="lj lk ll lm ln lo">
<section class="lr eu ev ak dc n ap ls lt lu lv lw lx ly lz ma mb mc md me mf mg">
<div class="mh n ex p mi mj">
<div class="mm r">
<div class="bd lp bc gp lq gr">Happy coding!</div>
</div>
</div>
</section>
</div>
</div>
</div>
</section>

<p>&nbsp;</p><p>The post <a href="http://kostacipo.stream/turn-your-commute-into-a-learning-experience/">10 Useful Git Commands You Should Know</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/turn-your-commute-into-a-learning-experience/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
