A lot of times I'm coding some test functionality and I forgot to branch on my changes before hand. Is there a git command that:
- Stashes my changes
- Branches
- Applies the stashed changes
A lot of times I'm coding some test functionality and I forgot to branch on my changes before hand. Is there a git command that:
If i understand you problem correctly you don't need to stash your changes before change your branch and Git will take that modified file to the other branch. This is working until the same was modified in the target branch.
Then you get a message that there are working tree modifications. Otherwise if you need another functionality write a short bash script for example which do the steps.
Yes, it is git-reset
//you are in the point of a working directory that you want to have in other branch
git checkout -b newTmpBranch
git reset --soft theBranchYouWantToGo
git checkout theBranchYouWantToGo
git branch -d newTmpBranch
The reason of the newTmpBranch is because git-reset move the branch that you are to the point of the repository that you command. Then, to protect the current branch, this temporal branch is useful.
The git-reset command moves your actual branch (the temporal one) to the position which you say.