git-rewrite-history

interactive rebase with --preserve-merges of all commits in the current branch

北慕城南 提交于 2020-05-10 20:50:11
问题 There seem to be some similar questions already, but none of them are exactly what I want. Let's say I have commit history like this * xxxxxxxH (HEAD -> B) Latest commit * (more commits) * xxxxxxxG (B) More commits * xxxxxxxF Merge branch 'master' into B |\ | * xxxxxxxE (master) Another commit on master | * (more commits here) | * xxxxxxxD Commit on master * | xxxxxxxC Another commit * | (more commits here) * | xxxxxxxB First commit on branch A |/ * xxxxxxxA (master) some commit Now I want to

Git: Bulk change of commit dates

自作多情 提交于 2020-04-16 08:33:48
问题 When I need to change the commit dates of various commits, I use an interactive rebase and change them one by one. How could I change them all in a single command ? In other words, I need to apply a given command to all commits that would be listed in an interactive rebase. Thanks 回答1: Adapted from https://stackoverflow.com/a/750182/7976758: #!/bin/sh git filter-branch --env-filter ' GIT_AUTHOR_DATE="2000-12-21 23:45:00" GIT_COMMITTER_DATE="`date`" # now export GIT_AUTHOR_DATE GIT_COMMITTER

Squashing Git commits after merging

泄露秘密 提交于 2020-02-24 11:02:28
问题 I have a feature branch that has a few commits (see below). Since branching, a few commits have been added to master too. So I merged master into the feature branch. git checkout feature git merge master This results in the below log history on the feature branch: * E (HEAD) merging master into feature |\ | * D feature commit 2 | | | * C feature commit 1 * | B master commit 2 |/ * A master commit 1 In reality the number of commits on the feature path is large (100+) and I'd like to squash

Intermingling merge-basing two history tails in Git

我是研究僧i 提交于 2020-01-14 03:13:09
问题 I have two Git repositories with separate histories. After much researching and a lot of tinkering, I wound up with a history that looks like this (using YYYY-DD as pseudo commit-hashes): HEAD---2016-09---2016-08---2016-07---2016-06 \-----2015-10---2015-09 Note that this history appears to have two "roots", as the 2015-10 sequence was merged/grafted into the middle. The important thing is that the files in the 2016-07 history and the 2015-10 history contain completely different files with

BFG Repo Cleaner – Alternative to Fresh Clone

懵懂的女人 提交于 2020-01-13 10:43:08
问题 I was going to ask this on the repository but SO seemed like a more fitting place to ask this. I was able to use BFG Repo Cleaner (great tool, thank you!) to reduce our .git folder size by over 1GB, which is a smashing success as far as our repository is concerned. I have not pushed my bare clone to remote yet, as I am concerned with putting forward these changes before understanding the consequences of pushing and then not re-cloning. I understand that best practice dictates that when

Change git email for previous commits

喜你入骨 提交于 2020-01-10 10:18:12
问题 So I read a lot about how to change previous commit's email address but for some reason mine is not updating. I did like 40 commits to my private repo with my local email (nameofMyComputer@kevin.local) which is bad since this email is not associated(and it can't be) with github. I then remembered that I needed to set the git.config before and so I did: git config user.email "newemail@example.com" and did a test commit and it worked perfectly. Is there a way I can revert all my previous

How to remove all commits of a topic Git branch?

我的未来我决定 提交于 2020-01-02 10:16:44
问题 Suppose I have the following history: A---B---C----------D------------E master \ /\ / W1--X1--Y1 W2--X2--Y2 topic1 topic2 Is it possible to remove all topic branches and their commits as following A-B-C-D-E master 回答1: You have a few options for doing this. Solution 1: Squash Merges One solution is to simply use a hard reset with a few squash merges: git checkout master git reset --hard C git merge --squash topic1 git commit -m "Rewrite D" git merge --squash topic2 git commit -m "Rewrite E" #

Can I rewrite an entire git repository's history to include something we forgot?

你说的曾经没有我的故事 提交于 2020-01-01 05:23:23
问题 We recently completed a conversion from Mercurial to Git, everything went smoothly, we were even able to get the transforms needed to make everything look / work relatively correctly in the repository. We added a .gitignore and got underway. However we're experiencing some extreme slowdowns as soon as we encorporate/work with any of our old feature branches. A little exploring and we found that since the .gitignore was only added to the develop branch when we look at other commits without

How to delete one folder / directory using BFG repo cleaner?

£可爱£侵袭症+ 提交于 2020-01-01 04:30:27
问题 How do I delete only one directory using BFG? The help says: delete folders with the specified names (eg '.svn', '*-tmp' - matches on folder name, not path within repo) Which seems to mean that --delete-folders "config" will match all folders named config, anywhere in the repository. 回答1: I found the answer here: remove files from specific path The author of BFG says it can't be done, unless you use a special command to dump all blobs for a given directory to a text file, and then use --strip

Really flatten a git merge

五迷三道 提交于 2019-12-28 11:46:38
问题 There're few question about "flattening merge" on StackOverflow, with an answer usually being "git rebase". These answers though miss one crucial point - order of commits. Suppose there's a branch A with commits of Jun 1 and Aug 1, and branch B with commit of Jul 1 ( UPDATE to reinstate the usecase described below: branches are fully independent and don't have common ancestry, for example coming from 2 different repositories). When merging B into A, there will be following history (per git