Git Workflow Issue: git push, git reset --soft HEAD~1 and how to push updated code to new branch?

Git Workflow Issue: git push, git reset --soft HEAD~1 and how to push updated code to new branch?



I am quite new to the git workflow. I made a mess and I need help to untangle it. This is what happened:



What I would like to do:



Any help is greatly appreciative.





You still could do a revert if you thing it's the right thing to do. Look at the command reflog to be able to reinstate how your history was. And then do your revert and (normal) push
– Philippe
Aug 29 at 12:26


revert


reflog


revert


push





Yes, that's what I ended up doing resetting my reset with git reset HEAD@1; and then git reflog to get the specific commit number and git revet <commit>. Thank you so much for help!
– lukrecija
Aug 31 at 19:07




1 Answer
1



When you did git reset, you only undid the commit locally. You need to make the same change in remote as well.


git reset


git reset --soft HEAD~1


git stash


--force-with-lease



WARNING: Be very careful when using --force-with-lease flag, you may lose changes. It's always a good idea to backup your code incase things go wrong.


--force-with-lease



Edit 1: This will work only if force pushes are allowed on the branch. If not, git revert is one option.



Edit 2: As pointed by philippe --force-with-lease is a better approach.


--force-with-lease



More info about --force-with-lease here.


--force-with-lease





--force-with-lease is most of the time much better than -f/--force and should be preferred to avoid loosing other developers commits
– Philippe
Aug 29 at 12:27


--force-with-lease


-f


--force





Interesting, I did not know about --force-with-lease.
– Rajeev Desai
Aug 30 at 6:54


--force-with-lease





Thank you Phillipe for taking the time to provide a solution. I was not comfortable doing the force flag (as i am still new to this and project is huge involving teams), so i just reverted my commit.
– lukrecija
Aug 31 at 19:10



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ