Reply New Topic
2015/8/29 20:50:19
#1
Offline
Home away from home

Helpful git commands

<p>Here's the first one - used it tonight to create the 'upgrade' package for 1.3.x to 1.3.8 Note: I use Ubuntu, so it won't work on a Windows machine!</p>

<blockquote>
<p>git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT [old commit hash] [new commit hash] | xargs tar -cvzf filename.tar.gz</p>
</blockquote>

<p>Here's how the command breaks down -</p>

<blockquote>
<p>git diff-tree -r [old commit hash] [new commit hash]</p>
</blockquote>

<p>Take a diff of the given commit to the older commit (including all subdirectories, not just the top directory).</p>

<blockquote>
<p>--no-commit-id --name-only</p>
</blockquote>

<p>Do not output the commit SHA1. Output only the names of the affected files instead of a full diff.</p>

<blockquote>
<p>--diff-filter=ACMRT</p>
</blockquote>

<p>Only show files added, copied, modified, renamed or that had their type changed (eg. file → symlink) in this commit. This leaves out deleted files.</p>

<blockquote>
<p>| xargs tar -cvzf filename.tar.gz</p>
</blockquote>

<p>Send the output to a tar.gz file. You can also run without this to just get a list, or send to a text file.</p>

<p></p>


Edited by skenow on 2020/1/8 18:56:45
Edited by skenow on 2020/1/8 19:00:13
_________________

Steve Twitter: @skenow Facebook: Steve Kenow


2015/8/30 0:29:29
#2
Offline
Webmaster

Re: Helpful git commands

Great contribution Steve, I'll try to integrate this into the Phing build file. Once we have the build file, that should make this kind of issues go away in newer releases I hope.

_________________

Me on Ohloh


2015/8/31 18:43:18
#3
Offline
Home away from home

Re: Helpful git commands

<p>There is a variant that is all git commands -</p>

<p><strong>git archive -o filename.zip [commit hash new] $(git diff --name-only --diff-filter=ACMRT [commit hash old] [commit hash new])</strong></p>

<p>It will create either a zip or a tar.gz archive, guessing which from the file extension. Or you can specify the type using -format=[type]</p>

<p>http://git-scm.com/docs/git-archive</p>

<p>Here's an example for getting the files changed between the 1.3.8 Final release and the 1.3.9 RC release:<br />
&nbsp;<br />
<strong>git archive -o impresscms-138-139rc.zip 8b451c0 $(git diff --name-only --diff-filter=ACMRT b182a01 8b451c0)</strong></p>

<p>I run this when I'm in my git repository directory for ImpressCMS</p>

<p><em>Edited Dec 31, 2018 to be able to see the commands</em></p>


Edited by skenow on 2016/2/27 14:44:09
Edited by skenow on 2018/12/31 19:05:26
Edited by skenow on 2018/12/31 19:07:11
_________________

Steve Twitter: @skenow Facebook: Steve Kenow


2016/2/27 15:02:01
#4
Offline
Home away from home

Re: Helpful git commands

I just had to update the sample command - I had an extra parameter in the diff portion and a missing one in the archive portion.

It's all good now - just tested and created my update package.

_________________

Steve Twitter: @skenow Facebook: Steve Kenow


2016/2/29 5:51:48
#5
Offline
Webmaster

Re: Helpful git commands

Great! This will make the creation of update packages that much easier. Thank you very much, I'll have a use for this this evening I think

_________________

Me on Ohloh


2017/2/23 23:44:14
#6
Guest_

Re: Helpful git commands

Thank you very much for the latest updates.


Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.