Josiah Victor
Josiah Victor

Reputation: 1

Pushing code to a non-existing branch in a repo

Cloning a repo and creating a branch on my local repo $ git checkout -b jovick-coder,
I made changes and added $ git add.
I made a commit $ git commit -m "first commit".
This branch is not created remotely.
First how will I push my code to the existing branch jovick-coder.

I used
$ git push and I got:

fatal: The current branch jovick-coder has no upstream branch.

To push the current branch and set the remote as upstream, use
git push --set-upstream origin jovick-coder

was suggested to me and I tried it. This is what I got then:

Enumerating objects: 23, done. Counting objects: 100% (23/23), done. Delta compression using up to 4 threads Compressing objects: 100% (22/22), done. error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8) Wsend-pack: unexpected disconnect while reading sideband packet Writing objects: 100% (22/22), 6.14 MiB | 99.00 KiB/s, done. Total 22 (delta 6), reused 0 (delta 0), pack-reused 0 fatal: the remote end hung up unexpectedly Everything up-to-date

please I need this help I am stuck

Upvotes: 0

Views: 662

Answers (1)

Abhimanyu Rathore
Abhimanyu Rathore

Reputation: 94

your git commands seems like correct

but as your question title says "Pushing code to a non-existing branch in a repo", answer for that is:

suppose your current local branch is "dev" then

git push origin dev:jovick-coder

it will create a new branch at remote if not exist else update if exists.

Upvotes: -1

Related Questions