Questions tagged [git-rewrite-history]
Rewriting the history of a Git repository, for example to edit old commits, remove unwanted data (e.g. private data or large files), rearrange file structure, fix commit metadata, etc.
325
questions
0
votes
0
answers
18
views
Git: Change authors through history [duplicate]
I work on a shared lab system with another person on a project. We have both been working on a project so we use the same user on the machine, but we are testing different parts of a code so we each ...
1
vote
2
answers
77
views
Rewrite history to remove all additions of lines matching a certain pattern
I have a range of commits in a C++ codebase. I added a particular include in a set of files that I want to undo for the whole range of commits. Is there any way of automatically going through the list ...
1
vote
2
answers
97
views
Putting unrelated histories behind each other
For some reason (due to complicated conversion from SVN) I have two Git repositories:
git repo A contains all history up to 31st December 2021
git repo B contains all history from 1st January 2022 on
...
-1
votes
2
answers
72
views
Rewording a commit message in a Git repository with a non linear history
I need to change the message of a past commit.
I tried the method described in How to reword a Git commit by its SHA1 hash?, viz. checking out the commit in question, amending its message and rebasing ...
0
votes
1
answer
54
views
Add a .gitignore file to every commit [duplicate]
I have a git repo that was converted from SVN. It lacks a .gitignore file.
Of course, I could just add one and commit it on main, but it would be better if it were present also on other branches and ...
4
votes
2
answers
56
views
How do I format all commits in a branch?
I'd like to run an auto-formatting tool (e.g. Prettier, go fmt, clang-format, terraform fmt ...) on all commits in a branch. I could manually edit each commit in the branch using an interactive rebase ...
1
vote
1
answer
52
views
Git rebase branch onto squash merge
I did a mess with my features branches. What I had:
master: A - B
\
branch1: E - F
\
branch2: G - H
And then
I squashed and merge ...
2
votes
0
answers
126
views
How to remove the message about initializing Git LFS when cloning a repository with GitHub Desktop?
A message about initializing Git LFS comes up when using GitHub Desktop to clone a repository that has previously used Git LFS. How can I remove this message?
This repository uses Git LFS. To ...
0
votes
1
answer
56
views
How to reapply Git tags after rewriting history using rebase?
I have a project where I'd started working on my old laptop and then continued on my new one. On my old laptop I had properly configured Git with user.name and user.email, but when I switched to my ...
0
votes
1
answer
29
views
How can I locally preserve as much git history as I can when the reference repository won't?
I recently realised the reference repository that our team pushes to was not configured to reject non-fast-forward updates.
Given the propensity of some team members to use history rewriting to clean ...
2
votes
3
answers
102
views
How can I modify a git commit which is part of the master branch without breaking the branch history?
There is a commit on master branch which I need to make some changes to.
Here's some history of what happened:
I was working on some code, and merged this to master
I created a new branch
Someone ...
0
votes
0
answers
21
views
How can I remove an unfinished commit from my Git history after finishing the task? [duplicate]
On my personal projects, I often have to switch the machine I am working on and therefore I use git to synchronize my progress. A side effect of this workflow is that I sometimes have to push ...
-3
votes
1
answer
121
views
Change Commit Message Without Rebasing?
I have a relatively old branch (2 weeks). After changes, I commit my code (with the message git commit -m "ABC commit") and then pull the main branch. I resolved a few conflicts and merge by ...
1
vote
2
answers
106
views
Is there a way to have a commit per day and per file automatically in git?
I use git-auto-commit-mode (https://github.com/ryuslash/git-auto-commit-mode) in Emacs to preserve my files automatically sync with my repo.
However, I got a massive list of commits per day (the ...
0
votes
0
answers
60
views
How to use git-filter-repo to remove change on an archive file, after a certain commit, and update every branchs and tags
I would like to rewrite git history using git-filter-repo to remove a file change, because it has become too large. I would like to keep the original file, so do it only after a certain commit, and ...
0
votes
1
answer
92
views
Interleaving two Git repositories
How can I join two Git repositories by interleaving their commit history according to commit / author date?
We can assume both repositories contain separate files. However, folder names might be ...
1
vote
1
answer
134
views
On Gitlab, is there a commonly used procedure, similar to a Merge Request, for changes that rewrite the git history?
Something we could call a "Reset Request", because instead of requesting to merge the feature branch into master, we'd be requesting to reset master to the feature branch.
The use-cases for ...
2
votes
2
answers
366
views
How to recreate git commit history but with applying pre-commit hook?
I'm trying to rewrite git repository history and apply new pre-commit hook:
Take every commit
Apply pre-commit hook
Keep the original metadata (author, date, message)
Resolve conflicts manually, if ...
0
votes
3
answers
87
views
Rewrite a file in an earlier commit then propagate that change to all later commits seamlessly
Suppose I have a series of commits like this.
(0) Initial commit
(1) Version 1
(2) Version 2
I already know that I can rewrite history without creating a new commit by using git rebase to edit, say, ...
0
votes
0
answers
91
views
Preservice git history while converting VB to C#
I've used fishcodelib's Convert .Net library to convert a VB-project to C#. It creates C#-files next to the vb ones. I've deleted the vb-ones and checked everything in.
I've got everything working, ...
-1
votes
1
answer
143
views
Git: How to remove intermediate commit? [duplicate]
Current Commit History
O- commit C HEAD
|
O- commit B
|
O- commit A ← I want to delete this commit
/
/ branch: feature/foo
/
0 -- master HEAD
Goal Commit History
O- ...
6
votes
2
answers
290
views
List all git commits that delete any file
Question
How can I list all the commits that delete any file in the repo? (not a specific file, but all the commits that delete anything).
Context
We have a multiple-years-old repo and we plan to ...
3
votes
2
answers
679
views
rewrite history to undo all changes to a file on current branch in git
Suppose I have a feature branch that modifies half a dozen files. Most of the commits on that branch involve file.py. I eventually realize that there's a potentially better way to implement this ...
1
vote
1
answer
1k
views
BFG Repo-Cleaner doesn't clean my gitlab repo
This is really worrying and stressful issue that I can't find any answer that works for me, so I cannot backup my code for over a year now (too bad!).
I am actually using BFG Repo-Cleaner to clean my ...
0
votes
1
answer
2k
views
How to delete all files > 1 Mb from the history (but keep them in the repository) [duplicate]
I have a repository with many big files (psd, exe, pdf, etc.) and everytime I commit an update of thoses files the git .pack file grow drastiquelly to keep the history. How can I delete all files > ...
11
votes
3
answers
7k
views
Remove a file from git history using git-filter-repo on a fresh clone
I'm following this answer to remove a single file containing credentials from git history. I have git 2.35.1 and filter-repo 22826b5a68b6. The command I need is apparently:
git-filter-repo --path auth....
1
vote
0
answers
44
views
Can not push backup to GitHub due to too large files
I am aware that this issue has several related issues, but I have a slightly backward problem, where there already is a commit history to preserve.
I have a project repo I worked on last year together ...
1
vote
2
answers
342
views
Rewriting Git history to place all work in a subfolder instead of root
I have a simple repository with linear history where work was done in the root folder. I would like to rewrite history so that all the work from every commit looks like it happened in the /server ...
0
votes
1
answer
179
views
Combining the history of two git repositories
I have git repo A. I also have git repo B, which is taken at some commit of repo A, but with the .git folder deleted and remade with git init. Some commits have been made in B. I now want to combine A ...
2
votes
1
answer
1k
views
How to undo a merge on a branch where there have been subsequent commits?
Let's say I have a develop branch where multiple people branch off of to work on either bugfixes or features.
Let's say now I have a branch called featureA that I worked on while some other person ...
1
vote
2
answers
414
views
(How) can I filter the commit log messages?
I extracted a new module from a git repository using git filter-branch ... (according the instructions I found in a book) repeatedly.
Basically I removed many unrelated files (i.e. "everything ...
3
votes
1
answer
1k
views
Delete list of files with BFG-repo-cleaner
We are trying to shrink our git repository to under 500MB due to deployment issues.
To achieve that, we have created a new branch where we have moved all old images, videos and fonts to AWS S3.
I can ...
0
votes
2
answers
667
views
git: Clean git history and keep only merged commits in master
In our git repo we have a policy to squash merge all the commits. Recently there was a policy update and some changes got merged with their local commits details into master. Is there a way I can ...
-1
votes
1
answer
202
views
How to remove old problematic git commits
Recently we found two old git commit from one of our ex team member, which is malicious and affected our entire repository. First commit deleted all files from repository and second commit added all ...
2
votes
2
answers
1k
views
Git interactive rebase did not delete my other commits
I have some commits in my current branch. I want to convert those all commits into one commit and delete all those commits. So I have used the following commands
git rebase -i HEAD~9
Edited all ...
0
votes
1
answer
111
views
Introduce a change in last n commits automatically
I have a bunch of commits:
T-1: commit-50
...
T-1: commit-1
Now I need to merge them under a new task. Is there a way to automatize turning them into
T-2: commit-50
...
T-2: commit-1
?
0
votes
1
answer
401
views
Is there a way to prevent dirty history being pushed to a repo?
I'm working with a repo that includes generated PDFs. Obviously this isn't a great idea, so we'd like to remove them from our repository history.1 I've tested out BFG Repo-Cleaner and the results are ...
1
vote
2
answers
455
views
Remove commit from history without changing anything else (dates, committers)
I expected this to be as easy as interactive rebase, but I've noticed that rebase changes commit dates and committers.
What would be the easiest way to remove a commit from history while leaving ...
0
votes
1
answer
152
views
How to delete commits from before a certain point?
At some point in the past, sensitive info was uploaded to a git repo. We removed this in the following commit and changed the info, but we'd still like to remove the original info from the git history,...
0
votes
0
answers
37
views
Collect all changed files and commit after merged
I have master look like
|
|
abcd3 Commit3 (file A, B)
|
|
abcd2 Commit2 (file C, D)
|
|
abcd1 Commit1 (file E)
|
|
and in my feature branch
xyz1 MyCommit (file A, B)
|
|
abcd1 Commit1 ...
1
vote
1
answer
121
views
Storing results of BFG to new project in Gitlab
I've successfully (I think!) removed large files from a gitlab project mirrored on my local drive using BFG. I don't want to replace the existing gitlab project (for safety reasons), but instead want ...
2
votes
2
answers
932
views
Why can I still see the file after deleting it using BFG
This are the steps I did:
Created an empty folder.
Mirrored my repository using:
git clone --mirror git@bitbucket.org:somespace/myrepo.git
Got a list of 10 largest file using the following command:
...
3
votes
1
answer
311
views
How to work around force-pushing of an upstream branch?
I have a feature branch branchX that is using some-remote/base-branch as its upstream branch. I just discovered that some-remote/base-branch got its history rewritten by a force-push. What are the ...
4
votes
1
answer
1k
views
Use git filter-repo to move a subdirectory to root while retaining files in root
I am attempting to split up a repository that contains a client and server into two repositories, and I want to move the respective folders to the root while also keeping the files I already had in ...
1
vote
0
answers
115
views
Retroactively set text files to binary with git
We have some files that go back a long ways that haven't been touched in a long while, and we realized the other day that they weren't marked as binary files.
Is there any way to rewrite our history ...
1
vote
1
answer
109
views
repair connection in git repo and merge with old repo to preserve history
PROBLEM
I have two code repositorys "REPO A" and "REPO B" which belong to the same project. In fact, REPO B is a continuation of REPO A and thus should include REPO A. I can not ...
1
vote
1
answer
58
views
How to add old project files midway to main branch
I have found 4 old versions of one file that I would like to add to a Git repository.
Initially, there is one single-ref main development line, as follows:
[ROOT] A - B - C - D - I - J - K - L - M [...
2
votes
0
answers
121
views
Removing or reset contributor from github.com?
I have done several commits with a wrong user, so I have renamed that commits with this script:
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="user2@example.com"
CORRECT_NAME="...
2
votes
1
answer
179
views
Automatic rebase to drop a commit that modifies a file?
I'm new to git rebase and doing something a bit wacky and stupid.
So let's say I have these commits which all modify the same file file.txt
a -> b -> c -> d -> e
I want to just remove ...
0
votes
1
answer
55
views
Split one branch into two in Git
I have a project with a completely linear history:
master A – B – C – D – E – F – G – H
I'd like to split it into two: develop with most of the commits, and master, into which develop merges only ...