I selected the master branch, made code changes, added couple of files, staged and committed everything locally. While pushing master to remote it gave me an error that pushes to master are not permitted. I understand that I was actually supposed to work with a new feature branch rather than on the master branch.
Now I have created a new feature branch off the master branch on the remote, connected to the feature branch locally and am not sure how to make the same commits on the feature branch?
One solution that I can think of is - connect to local master where the changes are made. Copy all the files from the folder and save it outside of the git folder. Then connect to the feature branch and paste the copied files, stage, commit and push to remote feature branch. Then, raise a pull request to merge feature branch into the master branch.
Another solution is to create a new feature branch off master locally. Then push that to the server and raise pull request on the server to merge into master. But then my local master and server master will be out of sync and once merge is done I will have to delete local folder and clone it again to match the local master with server master.
Is there any other elegant way than the one's mentioned above?