Git workflow
Clone an existing repo
git clone ##MY REPO##
Create a new branch
git checkout master # we want the branch starting from master
git branch feature
git checkout feature
Push a commit in the new branch
git add --all # or better, the new files one by one
git commit
git push origin feature
How to fix a push in a wrong branch:
Identify commit sha (-3 to see last 3 commits):
git log -1
Copy COMMIT_SHA.
Checkout to the wrong_branch you just pushed (probably already there):
git checkout wrong_branch
Revert the commit (repeat for any other commit sha you want to revert - starting from the most recent):
git revert COMMIT_SHA
Push remote if needed (git push -f).
Checkout to the good branch:
git checkout good_branch
Cherry pick the commit you want to recover (repeat for any other commit sha you want to revert - starting from the most recent):
git cherry-pick COMMIT_SHA
Extra github trick
Quickely edit the repository using VSCode online by changing github.com to github.dev in the repository link.