Skip to content

Recreates all commits (only the main chain) from a given repository & branch to a new repository & branch, excluding certain files as per configuration.

Notifications You must be signed in to change notification settings

Kukuster/git-copy-branch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Short Description

I. creates 2 dirs in the current dir:

  • dirread
  • dicreate

II. fetches the repo in the dirread

III. creates a new repo in the dircreate

IV. Loops through the commits in the specified branch in dirread, starting from the oldest commit; and for each commit it copies everything from dirread to dircreate except the specified Exceptions, and makes a commit in dircreate with the message name of the one in dirread. Thus effectively creates a new repository and copies all commits of a branch but excludes certain files and dirs completely from the tracking history.

Dependencies

  • git
  • rsync

Details

Merges are not preserved, only the main 1-d part of the branch is copied, navigating through the first parents starting from the latest commit in the branch.


dirread and dircreate names, Exceptions, repository url, and branch name are to be specified in config.sh file.


Also, as for Exceptions, higher-level paths work as well. E.g. putting "core/notes.txt" will only omit that file, preserving everything else in the "core" directory


A considerable chunk of the script is checks: if you have git and rsync installed, if there's a config.sh file in the current dir, if the specified remote repository exists and readable, etc. So that the script is unlikely to make some mess if something went wrong unintentionally.


This script doesn't push or affect your remote repository in any way. The only effect of this script is local, within the directory where the script is executed.
You can configure config.sh file, execute the script with bash, and check if the newly created repo works for you.
Output of all key executed git commands is preserved.

About

Recreates all commits (only the main chain) from a given repository & branch to a new repository & branch, excluding certain files as per configuration.

Topics

Resources

Stars

Watchers

Forks

Languages