Answer the question
In order to leave comments, you need to log in
How, in my case, to push a file from a local to a remote Git repository to another branch?
Good day!
I have a remote repository (let's call it *test*) which contains a master branch, gh-pages and an additional branch that comes from the gh-pages branch. I need to push a file from my local repository to a remote one in the additional branch. How can this be done?
Step by step I will expand my procedure:
1. Initialize the local repository:
git init
2. Add the file to be pushed to the index:
git add "index.html"
3. Make a commit:
git commit -m "add new sections"
4. Connect to the remote repository:
git remote add origin https://github.com/github-name/test.git
git push origin additional
=> error: src refspec additional does not match any
=> error: failed to push some refs to 'https://github.com/AlexeySmk/rsschool-cv.git'
git checkout -b additional
=> Switched to a new branch 'additional'
git push origin additional
! [rejected] additional -> additional (fetch first)
error: failed to push some refs to 'https://github.com/github-name/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question