C
C#2y ago
Paulvv

Delete changes on Github

I try to remove 3 brenches and keep the "master" brench. But i dont know how to do that.
24 Replies
Florian Voß
Florian Voß2y ago
failed to delete the branch from the remote repository, see the output window for more details
what does the output window say? do you only wanna remove branches or merge them into master / main?
Paulvv
PaulvvOP2y ago
Paulvv
PaulvvOP2y ago
remove the 3 incoming ones i dont want to merge them i want to delete them if possible they where mistakes
ZacharyPatten
ZacharyPatten2y ago
is the repo public? if yes please link
Paulvv
PaulvvOP2y ago
GitHub
GitHub - TheBaldCoder/TheBaldCoderBlog: My own blog website.
My own blog website. Contribute to TheBaldCoder/TheBaldCoderBlog development by creating an account on GitHub.
ZacharyPatten
ZacharyPatten2y ago
there are multiple ways to do what you want though. one of the easier options in my opinion is to make a branch off of the commit you want to revert to
Florian Voß
Florian Voß2y ago
there is only a master branch in this repo 🤔
ZacharyPatten
ZacharyPatten2y ago
and then force push that to your main branch
Florian Voß
Florian Voß2y ago
ohhhh he wants to revert commits
Paulvv
PaulvvOP2y ago
I'm so sorry its commits i'm so dumb
Florian Voß
Florian Voß2y ago
nah all good it was just a little missleading for me
ZacharyPatten
ZacharyPatten2y ago
you can use "git reset"
git reset --hard HEAD~3

git push --force origin master
git reset --hard HEAD~3

git push --force origin master
or you can make a branch off on the commit you want and then force push the branch to the master branch either of those options will work for you just be careful doing what you are doing in general you don't want to delete commits you just push a new commit to fix it
ZacharyPatten
ZacharyPatten2y ago
if you want to try the branch approach I mentioned:
Paulvv
PaulvvOP2y ago
but if i push a new one the changes "3 incoming" will be merged with it
ZacharyPatten
ZacharyPatten2y ago
yes what is your issue with that?
Paulvv
PaulvvOP2y ago
sorry i mean if i make a new commit. The other 3 incoming changes will merge with the changes i made. But i want to delete those 3 commits
ZacharyPatten
ZacharyPatten2y ago
yes I understand, and I gave you two options to remove the commits if you want to do that I'm just saying that in general you want to avoid deleting commits. it is generally better just to fix whatever the issue is with new commits commits are historical they help you find who changed what at a given point in time
Paulvv
PaulvvOP2y ago
Oh i thought it was for project control. If your project gets corrupted or something then you could go back to the previous version like a unity game that keeps crashing and you want to restore the changes you made
ZacharyPatten
ZacharyPatten2y ago
well returning to a previous version is definitely a use case for commits but also for history and finding out who made a change
Paulvv
PaulvvOP2y ago
but what is the proper way to do this? The 2 options you gave me?
ZacharyPatten
ZacharyPatten2y ago
I can't really answer that because "proper" is subjective are you still wanting to remove the comits? if yes, then either option I mentioend with give you the exact same outcome so either is fine
Paulvv
PaulvvOP2y ago
Thanks for the help. I'm making a different brench
ZacharyPatten
ZacharyPatten2y ago
yep, just make the branch on the commit you want to roll back to and then force push that branch into your master branch then you can delete the extra branch you made when you are done
Paulvv
PaulvvOP2y ago
i will thanks
Want results from more Discord servers?
Add your server