1

I am working on a branch, 'development'. On Github, I created a new branch called 'Temporary'. I want to push my current code to branch temporary.

In my workspace doing

git branch 

gives * development master

On trying,

git push origin temporary 

I get: src refspec temporary does not match any

The git show-ref doesn't show the branch either

What can I do to push to the new branch temporary?

2 Answers 2

2

You seem to be confused about Git's workflow. Typically, there are two possible scenarios here. The first is that you pull the temporary branch on GitHub to your local machine. You would then do some work and eventually sync up with GitHub by doing a git push origin temporary. The second scenario is that you create a local branch on your machine called temporary. You could do this from the master branch by doing git branch temporary. You would then push this branch to GitHub using git push origin temporary.

If you are certain that you really want to push the master branch to the temporary branch on GitHub, then you can force it by doing git push origin temporary --force

From your later comments, this is what you want to do:

git checkout master # work work work git checkout -b temporary git push origin temporary 
Sign up to request clarification or add additional context in comments.

7 Comments

That's not what I want to do. I pulled the development branch. I worked on it and made some changes. Now I want to push the changes. Not to the development branch, but a different temporary branch that I created.
git checkout -b temporary followed by git push origin temporary You don't create the branch on GitHub first...you create on it on your local machine and then push it to GitHub. Read my answer carefully.
Thanks. When I created the branch locally, I am still stuck on development as my current branch, even though it shows temporary. How do I move to the Temporary branch locally?
git checkout temporary
git checkout Temporary will switch to the branch, or if you are on master you could do git checkout -b Temporary to create the new branch and switch to it at the same time.
|
0

You should first create a branch locally and checkout to that new branch

git checkout -b temporary 

Make all changes, commit your code and then do this

git push origin temporary 

3 Comments

And are you currently on temporary branch?
No. While I was working on the development branch, I created the temporary brach on Github
Then you will have to pull that branch first

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.