git-rewrite-history

How to substitute text from files in git history?

巧了我就是萌 提交于 2019-11-27 06:16:32
I've always used an interface based git client (smartGit) and thus don't have much experience with the git console. However, I now face the need to substitute a string in all .txt files from history (so, not erasing the whole file but just substituting a string). I found the following command: git filter-branch --tree-filter 'git ls-files -z "*.php" |xargs -0 perl -p -i -e "s#(PASSWORD1|PASSWORD2|PASSWORD3)#xXxXxXxXxXx#g"' -- --all I tried this, and unfortunately noticed that while the password did get changed, all binary files got corrupted. Images, etc. would all be corrupted. Is there a

Removing '.git' directory from git repo?

你说的曾经没有我的故事 提交于 2019-11-27 05:53:40
问题 I'm trying to migrate a git repo from Kiln to Github. I can add the new remote just fine, but when I try to push master to the new remote, I get the following error: Counting objects: 8691, done. Delta compression using up to 8 threads. Compressing objects: 100% (3000/3000), done. remote: error: object a9ee490ac00987835de30bdbc851da5e8d45d28b:contains '.git' remote: fatal: Error in object error: pack-objects died of signal 13 error: failed to push some refs to 'git@github.com:Account/repo.git

Purging file from Git repo failed, unable to create new backup

自古美人都是妖i 提交于 2019-11-27 05:02:26
问题 I tried to remove a file from my remote repo by running: git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD But Git complains that Cannot create new backup. A previous backup already exists in refs/original/ Force overwriting the backup with -f rm: cannot remove /.git-rewrite/backup-refs : Permission denied rm: cannot remove directory /.git-rewrite : Directory not empty This was after I already deleted the .git-rewrite directory on Windows. How can I remove that

Remove refs/original/heads/master from git repo after filter-branch --tree-filter?

懵懂的女人 提交于 2019-11-27 02:33:23
I had the same question as asked here: New git repository in root directory to subsume an exist repository in a sub-directory I followed this answer here: New git repository in root directory to subsume an exist repository in a sub-directory Now, gitk --all shows two histories: one culminating in the current master , and one named original/refs/heads/master . I don't know what this second history is, or how to remove it from the repo. I don't need two histories in my repository. How do I get rid of it? To reproduce yourself: mkdir -p project-root/path/to/module cd project-root/path/to/module

Rebasing a Git merge commit

时光总嘲笑我的痴心妄想 提交于 2019-11-26 23:20:54
Take the following case: I have some work in a topic branch and now I'm ready to merge back to master: * eb3b733 3 [master] [origin/master] | * b62cae6 2 [topic] |/ * 38abeae 1 I perform the merge from master, resolve the conflicts and now I have: * 8101fe3 Merge branch 'topic' [master] |\ | * b62cae6 2 [topic] * | eb3b733 3 [origin/master] |/ * 38abeae 1 Now, the merge took me some time, so I do another fetch and notice that the remote master branch has new changes: * 8101fe3 Merge branch 'topic' [master] |\ | * b62cae6 2 [topic] | | * e7affba 4 [origin/master] | |/ |/| * | eb3b733 3 |/ *

git, filter-branch on all branches

允我心安 提交于 2019-11-26 22:35:35
问题 I'm using the following sources to expunge some large files and directories from my repository: http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/ Why is my git repository so big? git filter-branch only seems to work on the current branch - is there a way to apply it to all branches at once? 回答1: The solution is simple: git filter-branch [options] -- --all Note the four dashes (two sets of double dashes with a space in between) in -- --all . If you look at the docs for

Remove file from git repository (history)

丶灬走出姿态 提交于 2019-11-26 14:07:54
(solved, see bottom of the question body) Looking for this for a long time now, what I have till now is: http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/ and http://progit.org/book/ch9-7.html Pretty much the same method, but both of them leave objects in pack files... Stuck. What I tried: git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_name' rm -Rf .git/refs/original rm -Rf .git/logs/ git gc Still have files in the pack, and this is how I know it: git verify-pack -v .git/objects/pack/pack-3f8c0...bb.idx | sort -k 3 -n | tail -3 And this: git

Update a development team with rewritten Git repo history, removing big files

时光毁灭记忆、已成空白 提交于 2019-11-26 13:05:52
问题 I have a git repo with some very large binaries in it. I no longer need them, and I don\'t care about being able to checkout the files from earlier commits. So, to reduce the repo size, I want to delete the binaries from the history altogether. After a web search, I concluded that my best (only?) option is to use git-filter-branch : git filter-branch --index-filter \'git rm --cached --ignore-unmatch big_1.zip big_2.zip etc.zip\' HEAD Does this seem like a good approach so far? Assuming the

How to amend several commits in Git to change author

匆匆过客 提交于 2019-11-26 12:34:00
问题 I have made a series of commits in Git and I realise now that I forgot to set my user name and user email properties correctly (new machine). I have not yet pushed these commits to my repository, so how can I correct these commits before I do so (only the 3 latest commits on the master branch)? I have been looking at git reset and git commit -C <id> --reset-author , but I don\'t think I\'m on the right track. 回答1: Rebase/amend seems inefficient, when you have the power of filter-branch at

How to substitute text from files in git history?

。_饼干妹妹 提交于 2019-11-26 11:54:32
问题 I\'ve always used an interface based git client (smartGit) and thus don\'t have much experience with the git console. However, I now face the need to substitute a string in all .txt files from history (so, not erasing the whole file but just substituting a string). I found the following command: git filter-branch --tree-filter \'git ls-files -z \"*.php\" |xargs -0 perl -p -i -e \"s#(PASSWORD1|PASSWORD2|PASSWORD3)#xXxXxXxXxXx#g\"\' -- --all I tried this, and unfortunately noticed that while