git-rewrite-history

How to add a file to a specific commit with git filter-branch?

守給你的承諾、 提交于 2019-12-11 16:59:08
问题 We need to add some file in a specific past commit on a repo and we are ready to rewrite history so it affects to all branches diverging from that commit's children. We are trying to use git filter-branch for that, using add, since once we add the file to a commit it won't be added to the children, but we can't find the right parameters for stop it affecting to some concurrent diverging commits. See image for understanding. We are using this command targeting the red commit, but the file is

How to squash two commits which are actually before a merge commit?

自闭症网瘾萝莉.ら 提交于 2019-12-11 12:33:50
问题 assume the following history: X - Y - M - Z <- feature / / A - B - C - D <- master I want to rewrite history to fixup X and Y into a single commit. So i want the history look like this: X' - M'- Z' <- feature / / A - B - C - D <- master All of my attempts so far failed. Most of the time there are conflicts during the rebase. Maybe rebase is not the right way to achieve this? I understand that (without the knowledge that the effective situation just before the merge hasn't really changed)

How to squash a Git repository to a single commit and destroy everything else?

…衆ロ難τιáo~ 提交于 2019-12-11 05:28:00
问题 I would like to squash an entire Git repository down to a single commit, and actually remove all other commits. I have found several suggestions, including: $ git reset --soft <root-commit> This works with respect to the squashing, but it's still possible to checkout the previous commits if you know their id. How can I get rid off them as well? Maybe the simplest solution would be to delete the .git directory, and run git init again, wouldn't it? If I re-add the origin, and then use git push

Removing files from github

我是研究僧i 提交于 2019-12-11 02:27:11
问题 I have been using github for one project for some time now, but only as a issue tracker . So, tonight I devoted some time to get things going with code as well, and made a rookie mistake: I committed credential files and other unnecessary data. I have added those to the .gitignore file now and they should be not an issue anymore, but I see they are available in the history. That poses a security issue so I have to sort this out and remove that sensitive data there. I am the currently sole

Inspect git repo after using BFG repo-cleaner

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 09:35:49
问题 Very basic git question: I uploaded some compromising information to Github and am using bfg to clean the repo. I followed the documentation and performed the following actions: $ git clone --mirror git://example.com/some-big-repo.git $ bfg --replace-text passwords.txt my-repo.git I received the following output: Found 233 objects to protect Found 9 commit-pointing refs : HEAD, refs/heads/experimental, refs/heads/master, ... Protected commits ----------------- These are your protected commits

How to update/shrink the size of my github repo after running BFG Repo Cleaner

假装没事ソ 提交于 2019-12-09 14:50:10
问题 I have cleaned my repo with BFG Repo Cleaner using the following procedure: $ git clone --mirror git://example.com/some-big-repo.git $ java -jar bfg.jar --strip-biggest-blobs 500 some-big-repo.git $ cd some-big-repo.git $ git reflog expire --expire=now --all $ git gc --prune=now --aggressive $ git push I can see that my local repo has shrunk with 1GB. Great. The problem that I'm having now and that I haven't been able to find any info on is that now I would like to also shrink the size of the

Removing private information from old Git commits

青春壹個敷衍的年華 提交于 2019-12-09 08:28:36
问题 I have a project versioned with Git that I'd like to make open source, but it has some private information in it that is specific to the environment in which it was originally used. I'm going to change the information in question to load from a config file which is not included in the repository. I realize I should have done this in the first place, but since the private information still exists in previous commits, how can I go about removing it from my history? Do I just have to start a new

After using git filter-branch --subdirectory-filter how do I still use old repo and reclaim git space?

左心房为你撑大大i 提交于 2019-12-08 07:27:12
问题 I use git filter-branch to split a subfolder out into a new repository, refer to https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/ and https://stackoverflow.com/a/45983384/301513 My question is, according to the steps in the article, I need to create a new repo and git pull the-subdirectory-filter-result into the new repo. But is it possible I can still use old repo and reclaim the git space, i.e to make the old .git only has that subdirectory related metadata?

Squash older commits while preserving SHA1s of newer commits

十年热恋 提交于 2019-12-08 05:18:45
问题 I have a commit history like this: f85179d ten 7de4071 nine 5c7a482 eight 9585035 seven b41bffc six d102f05 five 5a28cb9 four 6fc27c9 three 524b0c7 two bb7e6ae one I would like to squash commits "one" to "five" into a single commit such that it looks like this: f85179d ten 7de4071 nine 5c7a482 eight 9585035 seven b41bffc six 4tg56y5 Squash five commits into one commit. Importantly, I want to keep the SHA values the same for the unsquashed commits. That means I cannot just use `git rebase -

Fix license in old Git commits

此生再无相见时 提交于 2019-12-08 00:40:52
问题 I have a currently private GitHub repository which exists for a few years now. In the README.md file there is a license, which is not accurate any more. Now I would like to turn this private repo into a public one, with the fixed license. Anyway, all of the old commits still contain the old (wrong) license. How could I solve this? My first idea was to squash the repository to a single commit and destroy everything else, but maybe there is a better way to achieve what I want. As you can see