I'm learning and adjusting my workflow integrating Git. My wish is to be able to push my development branch to my test server from my local terminal. My current setup is giving me an error once I branch of. I have the feeling it's not an error but Git doing its work, in combination with me not understanding it completely. Are you able to explain why this is happening and how to avoid it?
The Git "error"
! [remote rejected] feature -> feature (branch is currently checked out)
error: failed to push some refs to (I hide the ssh server address)
How I came to this situation:
- Create repo on github
- Include deployment keys generated via cpanel from my server
- Git clone on local machine
- Git clone on server via SSH
- Add server as remote to the repo as test
Flow
Adjusting master locally, pushing it to github and server all works fine. But my understanding is that the power of Git is create a branch for a 'feature' > test it > merge it to the master.
I make a branch called feature on my local machine
git checkout -b feature
- Make some changes to the repo and push it to origin and test
git add .
git commit -m 'added index.html'
git push origin feature (for backup/sync purposes)
git push test feature (to be able so see my code working on the test server
I have to 'checkout' the new branch in order to show the files on the server, so I SSH to my server and checkout the new branch:
git checkout feature
My thinking is, that from this point on, I can work on feature branch locally > commit adjustments and with a simple push command
git push test feature
I can test the code on my test server.
Broke the flow
But now my flow is broken. After I check out the feature branch on my server, I'm not able to push my adjusted branch to my remote test. Git returns the message shown above.