forked from tj/git-extras
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tj#357 from imsky/merge-repo
git-merge-repo
- Loading branch information
Showing
4 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
repo=$1 | ||
branch=$2 | ||
prefix=$3 | ||
flat=0 | ||
|
||
if test $prefix = "."; then | ||
prefix=$(mktemp -u 'git-merge-repo.XXXXXXX') | ||
flat=1 | ||
fi | ||
|
||
git subtree add -P "$prefix" "$repo" "$branch" "${@:4}" | ||
|
||
message=$(git log -1 --pretty=%B) | ||
|
||
if test $flat -eq 1; then | ||
git stash -u | ||
mv -i $prefix/* ./ | ||
git undo | ||
git add . | ||
git commit -am "$message" | ||
git stash apply | ||
rm -drf $prefix | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.\" generated with Ronn/v0.7.3 | ||
.\" http://github.com/rtomayko/ronn/tree/0.7.3 | ||
. | ||
.TH "GIT\-MERGE\-REPO" "1" "April 2015" "" "Git Extras" | ||
. | ||
.SH "NAME" | ||
\fBgit\-merge\-repo\fR \- Merge two repo histories | ||
. | ||
.SH "SYNOPSIS" | ||
\fBgit\-merge\-repo\fR <repo> <branch> <directory> [\-\-squash] | ||
. | ||
.SH "DESCRIPTION" | ||
Merges a repository\'s history with the current repository, inside a specified directory\. | ||
. | ||
.P | ||
Optional \fB\-\-squash\fR flag skips the full history and generates only one commit for the merge\. | ||
. | ||
.SH "EXAMPLES" | ||
Merges a local repo\'s \fBfrontend\fR branch into the current repo\'s \fBweb\fR folder: | ||
. | ||
.IP "" 4 | ||
. | ||
.nf | ||
|
||
$ git merge\-repo \.\./app/\.git frontend web | ||
. | ||
.fi | ||
. | ||
.IP "" 0 | ||
. | ||
.P | ||
Merges a remote repo\'s \fBmaster\fR branch into the current repo\'s folder: | ||
. | ||
.IP "" 4 | ||
. | ||
.nf | ||
|
||
$ git merge\-repo git@github\.com:tj/git\-extras\.git master \. | ||
. | ||
.fi | ||
. | ||
.IP "" 0 | ||
. | ||
.SH "AUTHOR" | ||
Written by Ivan Malopinsky <\fIhello@imsky\.co\fR> | ||
. | ||
.SH "REPORTING BUGS" | ||
<\fIhttps://github\.com/tj/git\-extras/issues\fR> | ||
. | ||
.SH "SEE ALSO" | ||
<\fIhttps://github\.com/tj/git\-extras\fR> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
git-merge-repo(1) -- Merge two repo histories | ||
============================================= | ||
|
||
## SYNOPSIS | ||
|
||
`git-merge-repo` <repo> <branch> <directory> [--squash] | ||
|
||
## DESCRIPTION | ||
|
||
Merges a repository's history with the current repository, inside a specified directory. | ||
|
||
Optional `--squash` flag skips the full history and generates only one commit for the merge. | ||
|
||
## EXAMPLES | ||
|
||
Merges a local repo's `frontend` branch into the current repo's `web` folder: | ||
|
||
$ git merge-repo ../app/.git frontend web | ||
|
||
Merges a remote repo's `master` branch into the current repo's folder: | ||
|
||
$ git merge-repo [email protected]:tj/git-extras.git master . | ||
|
||
## AUTHOR | ||
|
||
Written by Ivan Malopinsky <<[email protected]>> | ||
|
||
## REPORTING BUGS | ||
|
||
<<https://github.com/tj/git-extras/issues>> | ||
|
||
## SEE ALSO | ||
|
||
<<https://github.com/tj/git-extras>> |