I have created a branch for example with branch name branch1. I made some change to files, folders and also I have some untracked files. Only local, no adds or commit.
Now I want to return to origin/master so I can make the steps again from the beginning( trying to solve a problem in my site). I am thinking of these: git clean -f to clean all untracked files, git reset -hard to clean the branch, git branch -d branch_name, and in the end switch to master branch and pull files.
My real scenario is: I am having a online site with two servers. One for production and one for development. They are using my git. I made a new branch as I described. Then I run some scripts which were created some new untracked files and modified some other files. This didn't go right but I found the solution. So I want to return back to master and make the steps again from scratch. As I said all changes made in the development server locally. No adds or commits are made.
Am I missing something please? I don't want to mess up my git
Remove all untracked files with:
git clean --force
Removed all unstaged changes with:
git reset --hard
Go back to master branch with:
git checkout master
Then make and switch to a new branch with:
git checkout -b <newBranchName>
'git checkout master' will bring your files back to the state they were in on master. Since all edits were done on your local machine, there's no need to do a pull.
'git checkout -b ...' makes and switches you to a new branch so any changes you want to make will be on that new branch based on master.