Awarded GitHub Star since 2023 ⭐️ and Microsoft MVP since 2024 🔷 I talk about Open Source, GitHub, and Web Development.
I also run a YouTube channel called DevLeonardo, see you there!
Might be worth mentioning that in case you have a pushed commit, you can still do the same as for local commit if you have force rights on the repo.
git reset --soft HEAD~
And you get rid of the commit on your local branch, then
git push --force
And the commit is also gone from the upstream repo as well.
There are a few different ways to get a similar result (get code back to the previous state), it's good to know as many as possible to properly decide which one to use based on the situation :)
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
I'd add it but also explain in bold that this workaround with --force can also create issues with other team members commits if you're working on the same branch 😂
As you'll need to pull changes first
.. Won't be nice to find out a mate's commit disappeared suddenly 😅
I'd rather prefer to aim a single commit by it's hash identifier just to make sure.
Still double-checking before committing and using MR/PR process from an individual branch is king to avoid issues.
let Bio = {
username: 'hyggedev',
fullName: 'Chris Hansen',
bio: 'I create⚡️ fast modern, client-side websites with React and Javascript.',
passion: ['Blog', 'Tweet', 'Code']
};
Hey great article! Just to confirm on 'git revert.' After finding the hash, and using the command, it immediately updates the local files? Or does the remote repo become 'ahead' of local version and must we do a 'git pull' to accept updated changes again!? I'd test it but I'm out right now 😂💯
let Bio = {
username: 'hyggedev',
fullName: 'Chris Hansen',
bio: 'I create⚡️ fast modern, client-side websites with React and Javascript.',
passion: ['Blog', 'Tweet', 'Code']
};
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
Might be worth mentioning that in case you have a pushed commit, you can still do the same as for local commit if you have force rights on the repo.
And you get rid of the commit on your local branch, then
And the commit is also gone from the upstream repo as well.
There are a few different ways to get a similar result (get code back to the previous state), it's good to know as many as possible to properly decide which one to use based on the situation :)
Thanks a lot Leonardo!
Indeed there are a lot of different option to keep track of so thanks for adding these 💖
If you want you can also adjust my original article to include these? *(leaving that up to you)
I'd add it but also explain in bold that this workaround with
--forcecan also create issues with other team members commits if you're working on the same branch 😂As you'll need to pull changes first
.. Won't be nice to find out a mate's commit disappeared suddenly 😅
I'd rather prefer to aim a single commit by it's hash identifier just to make sure.
Still double-checking before committing and using MR/PR process from an individual branch is king to avoid issues.
Best regards
A better approach but it can cause issues if multiple people are working on same branch. i guess it can be tweaked abit more.
Hey great article! Just to confirm on 'git revert.' After finding the hash, and using the command, it immediately updates the local files? Or does the remote repo become 'ahead' of local version and must we do a 'git pull' to accept updated changes again!? I'd test it but I'm out right now 😂💯
The revert is still local, you'll need to push it to get up to date on the remote.
Ahhh ofc, what am I saying lol. Thanks 👌
It happens, luckily we have some good ways of ondoing it 💖
Yep, well still make mistakes time to time 😅
Great post, saving it for later. :)
My IDE has a command for dropping a commit. Don't know/don't care about how the cli does it.
Git reset soft is my favorite solution for cleaning up the history
Ah yes!
Big fan of using tools that do it for you.
Less struggle and less prone to mistakes.
👏👏👏
Great guide but I have a totally unrelated question.
What's the name of the shell prompt you're using?
I think that's in iTerm (could also be in WebStorm) not sure which one I used for this article.
Mainly look fancy due to OhMyZSH
Can to undo a git clean? ادعيه لجلب الحبيب