2

I have a private git repository with many files.

I want to disclose some of these files including the commit history on a public (github) repository.

Quite a few commits will have references to either the private as the to be public files.

How can I achieve this (easily)?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
dr jerry
  • 9,768
  • 24
  • 79
  • 122

1 Answers1

1

git cherry-pick

You can create new branch and with cherry pick choose the commits that you want to be public.

git-filter-branch

Filter out the "unwanted" content out of your branch and leave it with the desired content.

Put the unwanted files in your .gitignore file

Any file with in this list will not be tracked by git

--assume-unchanged flag

--assume-unchaged flag for any file in the repo which you don't wish to track changes any more

git-update-index

--[no-]assume-unchanged

When this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167