#modify git history
1 messages · Page 1 of 1 (latest)
<@&987246964494204979> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
I have made a seperate branch which I called test and hard reset to the commit d3dfe5b364d379dda65997036bc2edd154811350 right before the rebase
this is the currenty history on the original dev branch:
the last commit of #42 is the state I was able to restore on my test branch
hi
HEY
now if I want to move any higher up the commits I wipe this entire history because of the rebase
is there any way to just exclude that one rebase from the history and keep the original commits
i found this aswell so far
ok wait
let me pull up my history
I found that I can do "git rebase -i HASH" where hash is the hash of the commit of the rebase?
but I dont know what todo inside the window to achieve this
before we start make sure you have a core.editor property in your git global config
is to help you change the history
you'll get your commits written on a file with some tips
you change the file, save it and close the editor
where and how do I add this property, is it .git/config ?
no
oh wait global config, one moment let me figure this out
do you have at least notepad++?
git bash will open an editor in terminal, you need to be aware of how to save it when you finish
i assume :wq
im windows user
alright, I'll just use the tools you are familiar with because I dont know how to solve this and ive been stuck for 3 hours
which tools do you use I'll get those then instead
install notepad or something equivalent
ok got that
are you on windows ?
yes sir
use powershell
opened
check your git global config with git config --global -l
[email protected]
user.name=hawolt
user.signingkey=redacted
commit.gpgsign=true```
alright theres no core.editor
Detected code, here are some useful tools:
that means you don't have a config for core editor
yeah but what value do I have to put?
Frustrated every time you forget to add a Git commit message and Vim, the default Git editor pops up? Here's a way to make issuing git commits a bit friendlier. In this Git tutorial, we show you ...
check this example
oh this config is
okok i get what this config is for
let me set it to notepad++
ok done
got it configured to notepad++
again pls
git config --global -l
[email protected]
user.name=hawolt
user.signingkey=redacted
commit.gpgsign=true
core.editor=C:/Program Files/Notepad++/notepad++.exe
Detected code, here are some useful tools:
let me put my test branch up to date with dev
like this
git rebase -i HEAD~<number_of_commits_you_want_to_backup>
like this git rebase -i HEAD~2
if you have merges the command would need additional keyword
theres merges from pull requests yes
maybe its easier if i just link it?
so i dont exclude something that might be important
since I dont know whats needed
if you have merges and want to manipulate them as well
do you ?
theres been merges from various pull requests
I dont want to manipulate those
I only want to get rid of the rebase I did
last week
check the test branch
thats where I do it on
the rebase happened here with fix game launching
you want to go back there ?
wait mabye im even using wrong wording
if you click on #42 for example
it has alot of commits
i want them to be visible in the history
rather than just one commit that sums it all up
i mangaged todo it to the point of the last commit in #42
ahaa
but if i go any further
it goes back to this state
because something happened? i think it was a rebase
my community told me todo it
and now it always accredits all amount of lines to everyone that contributed in the big squash/merge/base
i dont really know the words im learning how to use git
😭
git fetch -u origin dev 84977829beec6810504582fe53af5a555f70ad6c
git reset --hard 84977829beec6810504582fe53af5a555f70ad6c
git push -f -u origin test
if i do this then I have my full and exact history up until august 22
Detected code, here are some useful tools:
if those commits were done previously
thats how far i came so far
if the commits you're talking about were squashed into one
you can still see them in git
yeah the problem with the squashing is uh
if i add 3k lines
and another person in the squash added 1 line
we both get +3001 lines
as a contributor
i inflated everyones numbers this way
I owuld like to fix that
everyone got 3074 because they were included in the squash
is there any way to undo that squash?
yeah well! you just need to know how
thats where i fail
i managed to unsquash all up until aug 22, by just hard resetting to some point
but then i dont know how to pull in the rest
ohhhhhhhhhhh
wait maybe yes
i just point the thing somewhere else
so it skips that part?
i had that open earlier but it confused me more
so i just closed that tab
yeah i can see the rebase in the history
ill see what i can do with this
in git reflog*
Reflogs track Git refs updated in the local repository. In addition, branch tip reflogs, a special reflog is maintained for the Git stash. Learn more.
read more here
there is an example how to restore squashed commit(s)
yeah thats basically what I did with my hard reset
the problem is that there have been commits happening after this
this example works fine
but then I still lose all the commits that happened after to where I reset to
like right now I am on the last commit of #42 before everything was squashed
actually nevermind, every pull request i merged was also squashed
#19 aswell
yeah pick means: the rebase will pick all those commits
you can change that pick with something else
you can see a list of options below
you can see the commits you're looking for right ?
I dnt see anything would you like to show what you see rn ?
im using vim
but thats the rebase window
i can move on to the next file
but i dont really understand whats happening
did you recover the squashed commits ?
well they dont appear to be squashed from what i can see here
one moment
i see the entiry commit history except for merges / prs
if I add the -r you told me to the rebase i get an error
wait
oh wait
ok now i see it
or do i have to modify this on the main branch
when i open this in rebase
all i see is
need to leave for today, if anyone else has an idea how to recover all commits from the squashed merges within an active history please let me know
i think you need to add something in your rebase command
maybe this would help
git rebase -i --root -r HEAD~<commit_id>
im going to try it out