mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
commit
f2a3e50cab
|
|
@ -15,6 +15,7 @@
|
|||
- [`git commits-since`](#git-commits-since)
|
||||
- [`git contrib`](#git-contrib)
|
||||
- [`git count`](#git-count)
|
||||
- [`git cp`](#git-cp)
|
||||
- [`git create-branch`](#git-create-branch)
|
||||
- [`git delete-branch`](#git-delete-branch)
|
||||
- [`git delete-merged-branches`](#git-delete-merged-branches)
|
||||
|
|
@ -786,6 +787,14 @@ If you wish to omit the config section, you may use `--no-config`:
|
|||
$ git info --no-config
|
||||
```
|
||||
|
||||
## git cp
|
||||
|
||||
Copy a file to another one keeping its history and allowing for merge conflicts handling.
|
||||
|
||||
```bash
|
||||
$ git cp README.md README.rst
|
||||
```
|
||||
|
||||
## git create-branch
|
||||
|
||||
Create local branch `name`:
|
||||
|
|
|
|||
40
bin/git-cp
Executable file
40
bin/git-cp
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PROGRAM=$0
|
||||
CURRENT_FILENAME=""
|
||||
DESTINATION_FILENAME=""
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo 1>&2 "USAGE: ${PROGRAM} CURRENT_FILENAME DESTINATION_FILENAME"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
key="$1"
|
||||
|
||||
if [[ "$CURRENT_FILENAME" == "" ]]; then
|
||||
CURRENT_FILENAME=$key
|
||||
elif [[ "$DESTINATION_FILENAME" == "" ]]; then
|
||||
DESTINATION_FILENAME=$key
|
||||
else
|
||||
usage
|
||||
exit 30 # Error during arguments parsing
|
||||
fi
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
if [[ "$DESTINATION_FILENAME" == "" ]]; then
|
||||
usage
|
||||
exit 20 # Missing arguments CURRENT_FILENAME
|
||||
elif [[ "$CURRENT_FILENAME" == "" ]]; then
|
||||
usage
|
||||
exit 10 # Missing arguments CURRENT_FILENAME
|
||||
else
|
||||
echo "Coping $CURRENT_FILENAME into $DESTINATION_FILENAME"
|
||||
cp -r "${CURRENT_FILENAME}" "${DESTINATION_FILENAME}"
|
||||
|
||||
git add "$DESTINATION_FILENAME"
|
||||
git commit -m "Duplicate ${CURRENT_FILENAME} history in ${DESTINATION_FILENAME} history." -n
|
||||
fi
|
||||
|
|
@ -49,6 +49,10 @@ _git_count(){
|
|||
__gitcomp "--all"
|
||||
}
|
||||
|
||||
__git_cp(){
|
||||
__git_complete_file
|
||||
}
|
||||
|
||||
_git_delete_branch(){
|
||||
__gitcomp "$(__git_heads)"
|
||||
}
|
||||
|
|
|
|||
24
man/git-cp.1
Normal file
24
man/git-cp.1
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
.\" generated with Ronn-NG/v0.9.0
|
||||
.\" http://github.com/apjanke/ronn-ng/tree/0.9.0
|
||||
.TH "GIT\-CP" "1" "March 2020" "" "Git Extras"
|
||||
.SH "NAME"
|
||||
\fBgit\-cp\fR \- Copy a file keeping its history
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-cp\fR <current_filename> <destination_filename>
|
||||
.SH "DESCRIPTION"
|
||||
Copy a file keeping its git history\. This allows merge conflict handling\.
|
||||
.SH "EXAMPLES"
|
||||
Copy README into README\.txt
|
||||
.IP "" 4
|
||||
.nf
|
||||
$ git cp README README\.txt
|
||||
.fi
|
||||
.IP "" 0
|
||||
.SH "AUTHOR"
|
||||
Written by Rémy Hubscher <\fI\%mailto:hubscher\.remy@gmail\.com\fR>
|
||||
.SH "REPORTING BUGS"
|
||||
<\fI\%https://github\.com/tj/git\-extras/issues\fR>
|
||||
.SH "SEE ALSO"
|
||||
<\fI\%https://github\.com/tj/git\-extras\fR>
|
||||
.P
|
||||
<\fI\%https://stackoverflow\.com/questions/16937359/git\-copy\-file\-preserving\-history/44036771#44036771\fR>
|
||||
114
man/git-cp.html
Normal file
114
man/git-cp.html
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html;charset=utf8'>
|
||||
<meta name='generator' content='Ronn-NG/v0.9.0 (http://github.com/apjanke/ronn-ng/tree/0.9.0)'>
|
||||
<title>git-cp(1) - Copy a file keeping its history</title>
|
||||
<style type='text/css' media='all'>
|
||||
/* style: man */
|
||||
body#manpage {margin:0}
|
||||
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
|
||||
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
|
||||
.mp h2 {margin:10px 0 0 0}
|
||||
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
|
||||
.mp h3 {margin:0 0 0 4ex}
|
||||
.mp dt {margin:0;clear:left}
|
||||
.mp dt.flush {float:left;width:8ex}
|
||||
.mp dd {margin:0 0 0 9ex}
|
||||
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
|
||||
.mp pre {margin-bottom:20px}
|
||||
.mp pre+h2,.mp pre+h3 {margin-top:22px}
|
||||
.mp h2+pre,.mp h3+pre {margin-top:5px}
|
||||
.mp img {display:block;margin:auto}
|
||||
.mp h1.man-title {display:none}
|
||||
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
|
||||
.mp h2 {font-size:16px;line-height:1.25}
|
||||
.mp h1 {font-size:20px;line-height:2}
|
||||
.mp {text-align:justify;background:#fff}
|
||||
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
|
||||
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
|
||||
.mp u {text-decoration:underline}
|
||||
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
|
||||
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
|
||||
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
|
||||
.mp b.man-ref {font-weight:normal;color:#434241}
|
||||
.mp pre {padding:0 4ex}
|
||||
.mp pre code {font-weight:normal;color:#434241}
|
||||
.mp h2+pre,h3+pre {padding-left:0}
|
||||
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
|
||||
ol.man-decor {width:100%}
|
||||
ol.man-decor li.tl {text-align:left}
|
||||
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
|
||||
ol.man-decor li.tr {text-align:right;float:right}
|
||||
</style>
|
||||
</head>
|
||||
<!--
|
||||
The following styles are deprecated and will be removed at some point:
|
||||
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
|
||||
|
||||
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
|
||||
.man-navigation should be used instead.
|
||||
-->
|
||||
<body id='manpage'>
|
||||
<div class='mp' id='man'>
|
||||
|
||||
<div class='man-navigation' style='display:none'>
|
||||
<a href="#NAME">NAME</a>
|
||||
<a href="#SYNOPSIS">SYNOPSIS</a>
|
||||
<a href="#DESCRIPTION">DESCRIPTION</a>
|
||||
<a href="#EXAMPLES">EXAMPLES</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
<a href="#SEE-ALSO">SEE ALSO</a>
|
||||
</div>
|
||||
|
||||
<ol class='man-decor man-head man head'>
|
||||
<li class='tl'>git-cp(1)</li>
|
||||
<li class='tc'>Git Extras</li>
|
||||
<li class='tr'>git-cp(1)</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<h2 id="NAME">NAME</h2>
|
||||
<p class="man-name">
|
||||
<code>git-cp</code> - <span class="man-whatis">Copy a file keeping its history</span>
|
||||
</p>
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-cp</code> <current_filename> <destination_filename></p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
<p>Copy a file keeping its git history. This allows merge conflict handling.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p>Copy README into README.txt</p>
|
||||
|
||||
<pre><code>$ git cp README README.txt
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Rémy Hubscher <<a href="mailto:hubscher.remy@gmail.com" data-bare-link="true">hubscher.remy@gmail.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
<p><<a href="https://github.com/tj/git-extras/issues" data-bare-link="true">https://github.com/tj/git-extras/issues</a>></p>
|
||||
|
||||
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||||
|
||||
<p><<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>></p>
|
||||
|
||||
<p><<a href="https://stackoverflow.com/questions/16937359/git-copy-file-preserving-history/44036771#44036771" data-bare-link="true">https://stackoverflow.com/questions/16937359/git-copy-file-preserving-history/44036771#44036771</a>></p>
|
||||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>March 2020</li>
|
||||
<li class='tr'>git-cp(1)</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
30
man/git-cp.md
Normal file
30
man/git-cp.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
git-cp(1) -- Copy a file keeping its history
|
||||
============================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-cp` <current_filename> <destination_filename>
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Copy a file keeping its git history. This allows merge conflict handling.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
Copy README into README.txt
|
||||
|
||||
$ git cp README README.txt
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Written by Rémy Hubscher <<hubscher.remy@gmail.com>>
|
||||
|
||||
## REPORTING BUGS
|
||||
|
||||
<<https://github.com/tj/git-extras/issues>>
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
<<https://github.com/tj/git-extras>>
|
||||
|
||||
<<https://stackoverflow.com/questions/16937359/git-copy-file-preserving-history/44036771#44036771>>
|
||||
|
|
@ -37,6 +37,7 @@ git-extras(1) -- Awesome GIT utilities
|
|||
- **git-commits-since(1)** Show commit logs since some date
|
||||
- **git-contrib(1)** Show user's contributions
|
||||
- **git-count(1)** Show commit count
|
||||
- **git-cp(1)** Copy a file keeping its history
|
||||
- **git-create-branch(1)** Create branches
|
||||
- **git-delete-branch(1)** Delete branches
|
||||
- **git-delete-merged-branches(1)** Delete merged branches
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ git-coauthor(1) git-coauthor
|
|||
git-commits-since(1) git-commits-since
|
||||
git-contrib(1) git-contrib
|
||||
git-count(1) git-count
|
||||
git-cp(1) git-cp
|
||||
git-create-branch(1) git-create-branch
|
||||
git-delete-branch(1) git-delete-branch
|
||||
git-delete-merged-branches(1) git-delete-merged-branches
|
||||
|
|
|
|||
Loading…
Reference in a new issue