Protected branch and commits #22566
-
Im using the GitHub extension for Visual Studio. I have a project with a protected branch (master). A friend of my have cloned the project through visual studio, and forgot to make a new branch before making a change and a commit. He cannot push this commit to GitHub. Which is good. But how can he remove the change/commit he made locally, so it will disapear from the commits to sync? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Maybe you need the stash command: git-stashing |
Beta Was this translation helpful? Give feedback.
-
Nope, stashing is used to save current work temporarily (on a stash, hence the name). WARNING: The command below will PERMANTENTLY delete the commit! Use with caution - never execute commands random people on the internet suggest without having a backup and knowing what they do! Try:
This will undo the last commit and leave your current changes as they are. |
Beta Was this translation helpful? Give feedback.
-
You are right… But instead of stashing he can create a new branch from the local master and push to origin this new branch, then reset the local master to origin/master. Whit this method no modify were lost and they can review from a PR in github. In line there are the commands you need to run:
this command will create a new branch keeping all the changes made. Then push this new_branch to origin:
Return to master:
and reset with the origin master with:
This done the trick. -Gabriele- |
Beta Was this translation helpful? Give feedback.
You are right… But instead of stashing he can create a new branch from the local master and push to origin this new branch, then reset the local master to origin/master. Whit this method no modify were lost and they can review from a PR in github.
In line there are the commands you need to run:
this command will create a new branch keeping all the changes made.
Then push this new_branch to origin:
Return to master:
and reset with the origin master with:
This done the trick.
-Gabriele-