sethrobertson / gitfixum Goto Github PK
View Code? Open in Web Editor NEWOn undoing, fixing, or removing commits or mistakes in git
Home Page: http://sethrobertson.github.com/GitFixUm
On undoing, fixing, or removing commits or mistakes in git
Home Page: http://sethrobertson.github.com/GitFixUm
So, i was on master, made some changes to a file, before i could commit, someone else from the team merged a branch to the master. I know i should never commit directly to master, lesson learnt the hard way :( but then i committed my changes onto the master (i had the copy of master before someone else did the branch merge) Now my commit seems to break the master. I want to revert back to the place where merge was made by someone else. i have my changes which i can add later. i cant find a way to revert back to that commit.
Please help me out whats the best way to fix it.
Can I freely fork this repo and release a new version based on your work?
Helped me out today git reset --hard @{u}
i love this. it would look really pretty as a nice interactive site with jquery or angular to eliminate clutter. what to team up and make it look nice (err, nicer)?
Your page is a treasure trove of answer to intermediate and advanced Git problems. Thanks for compiling this page together!
Thanks to Seth for creating a well structured HTML document.
Reverse transcriptlaze:
What about the case where whole files were comitted and pushed sometime back in the history. Suppose further that Git was only being used internally to the organisation and but now the entire repo is to be published, except for those few particular files that should not be published due to privacy concerns. Is there a clear and safe way in Git to handle this case and "rewrite hisory" because I'm not a bad person? I don't want these files to be accessible even with reflog.
This is a change that I sometimes want to introduce and I always end up tagging the commit to be rewritten, reset --hard
to the previous one, checkout
file by file and add -p
to make sure I'm adding just what I need, and a rebase
of the older branch. I find this process to be painful, very painful (and I couldn't think of a better way); and I was wondering if you had any ideas to make it easier to digest.
every 15 days we want to run a job which remove history from repository and just contains only recent 15 days history(recent 15 days commit history) and after 15 days history we don't want to maintain in repository. We only want to maintain recent 15 days history.
Complicated worse than git itself
Thank you! I absolutely love this. It has helped me many, many times, but for the first time I reached the end and still wasn't sure what to do.
I got to the point where I needed to revert a merge but that particular merge was from a branch that had recently branched of master and so when it was merged in there was no merge commit. It just put all the commits in as if they had been made individually to master.
I found out that I could revert each commit individually, but I am wondering if there is a better way. Either way, it might be helpful to add a note that there may not be a merge commit available to be reverted in some cases.
This page is a marvellous idea which helped me to solve git issues time and time again!
--preserve-merges
(aka -p
) isn't supported, as of Git 2.35.0:
https://developercommunity.visualstudio.com/t/Git-no-longer-supports-preserve-merges/1671071
Today, I was removing an entire commit via git rebase -p --onto SHA^ SHA
, and ran into this error:
fatal: --preserve-merges was replaced by --rebase-merges
Fortunately, all I had to do was replace -p
with -r
!
I know this repo hasn't had an update in a while, but I figure, maybe this will help someone -- and, what the heck, I'll submit a PR just in case.
TL;DR: To remove an entire commit, the command is:
git rebase -r --onto SHA^ SHA
(yes: -r
– no: -p
)
In the "Changing a single commit involving only simple commits" section, the intended link to "Post-Production Editing using Git" seems to have not been properly translated into a real link. I don't know Markdown well, but I suspect it's a pretty simple syntax tweak. I tried to fork+fix, but couldn't find the source on Github to make it as easy for you as a pull req.
Thanks for the good information. Hope everything goes well.
It would be great to support offline mode. This document would be useful to have, even when not online.
I suggest adding an application cache.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.