Why Can't I Use 'git push origin/develop'?
Asked by David Newey:

Every time I try to push to the repository, I end up having to create a new ssh key and it has become a real pain in the you know what. However, I have discovered this time around that I may be using what to Bit Bucket is an incorrect command. I was in my 'develop' branch, working tree clean but with 4 commits to be pushed to the repo. I ensured the ssh-agent was activated, added the previous ssh key and entered the command:

git push origin/develop

And I got an error. This has happened every time I have tried to push to the repo and I go through all sorts of gyrations, including creating new keys, until at some point it finally works. I am attaching a printout of my session. This time after going through all the gyrations, just on a whim I typed:

git push

And it worked!

I hadn't worked with Bit Bucket until this year. I am used to working with Git Hub and I always used the syntax, 'git push origin/develop' or 'git push origin/master' and it has never been a problem until I started using Bit Bucket. Is it my stupidity that I didn't know I should be using 'git push' without the 'origin/develop' or is this a bug I keep running into? You can look at the attached session and see that I essentially did everything right, other than that.

BELOW IS THE PRINT OUT OF MY SESSION:

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git status  
On branch develop  
Your branch is ahead of 'origin/develop' by 4 commits.  
(use "git push" to publish your local commits)

nothing to commit, working tree clean

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ eval $('ssh-agent')  
Agent pid 658

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add \~/.ssh/id_rsa_cs  
Enter passphrase for /c/Users/dnewey/.ssh/id_rsa_cs:  
Identity added: /c/Users/dnewey/.ssh/id_rsa_cs (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add \~/.ssh/id_rsa  
Enter passphrase for /c/Users/dnewey/.ssh/id_rsa:  
Identity added: /c/Users/dnewey/.ssh/id_rsa (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh -T git@bitbucket.org  
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin develop  
Unauthorized  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add -l  
3072 SHA256:iGK27Uh70UQonXMWwlPyCa0A5Rwz3WdK+TCiym4ypGo CORP+dnewey@DESKTOP-8PUBBUL (RSA)  
3072 SHA256:916Ch30WKDrIXIDvwk+Ooiti7GbndfTKvLGyTq+rcyQ CORP+dnewey@DESKTOP-8PUBBUL (RSA)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add -d \~/.ssh/id_rsa_cs  
Identity removed: /c/Users/dnewey/.ssh/id_rsa_cs RSA (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add -d \~/.ssh/id_rsa  
Identity removed: /c/Users/dnewey/.ssh/id_rsa RSA (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add \~/.ssh/id_rsa_org  
Enter passphrase for /c/Users/dnewey/.ssh/id_rsa_org:  
Identity added: /c/Users/dnewey/.ssh/id_rsa_org (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add -d \~/.ssh/id_rsa_org  
Identity removed: /c/Users/dnewey/.ssh/id_rsa_org RSA (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-keygen  
Generating public/private rsa key pair.  
Enter file in which to save the key (/c/Users/dnewey/.ssh/id_rsa): /c/Users/dnewey/.ssh/id_rsa_dev  
Enter passphrase (empty for no passphrase):  
Enter same passphrase again:  
Your identification has been saved in /c/Users/dnewey/.ssh/id_rsa_dev  
Your public key has been saved in /c/Users/dnewey/.ssh/id_rsa_dev.pub  
The key fingerprint is:  
SHA256:eELJ6bXbbD2+MrJxhQln6MOb+iiEvxlEfvr7Ixm+kY0 CORP+dnewey@DESKTOP-8PUBBUL  
The key's randomart image is:  
+---\[RSA 3072\]----+  
\| \|  
\| . o . \|  
\| . = + o \|  
\| o o = = o \|  
\| .o = S o . \|  
\| ...o.\* B o \|  
\| oo.Eo\* = o \|  
\| o+++o+o. . \|  
\| oo\*\*++ oo. \|  
+----\[SHA256\]-----+

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh-add \~/.ssh/id_rsa_dev  
Enter passphrase for /c/Users/dnewey/.ssh/id_rsa_dev:  
Identity added: /c/Users/dnewey/.ssh/id_rsa_dev (CORP+dnewey@DESKTOP-8PUBBUL)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh -T git@bitbucket.org  
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ ssh -v git@bitbucket.org  
OpenSSH_8.5p1, OpenSSL 1.1.1k 25 Mar 2021  
debug1: Reading configuration data /etc/ssh/ssh_config  
debug1: Connecting to bitbucket.org \[104.192.141.1\] port 22.  
debug1: Connection established.  
debug1: identity file /c/Users/dnewey/.ssh/id_rsa type 0  
debug1: identity file /c/Users/dnewey/.ssh/id_rsa-cert type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_dsa type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_dsa-cert type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ecdsa type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ecdsa-cert type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ecdsa_sk type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ecdsa_sk-cert type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ed25519 type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ed25519-cert type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ed25519_sk type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_ed25519_sk-cert type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_xmss type -1  
debug1: identity file /c/Users/dnewey/.ssh/id_xmss-cert type -1  
debug1: Local version string SSH-2.0-OpenSSH_8.5  
debug1: Remote protocol version 2.0, remote software version conker_f5d238a74c 528818a67cd1  
debug1: compat_banner: no match: conker_f5d238a74c 528818a67cd1  
debug1: Authenticating to bitbucket.org:22 as 'git'  
debug1: load_hostkeys: fopen /c/Users/dnewey/.ssh/known_hosts2: No such file or directory  
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory  
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory  
debug1: SSH2_MSG_KEXINIT sent  
debug1: SSH2_MSG_KEXINIT received  
debug1: kex: algorithm: curve25519-sha256@libssh.org  
debug1: kex: host key algorithm: rsa-sha2-512  
debug1: kex: server-\>client cipher: chacha20-poly1305@openssh.com MAC: \<implicit\> compression: none  
debug1: kex: client-\>server cipher: chacha20-poly1305@openssh.com MAC: \<implicit\> compression: none  
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY  
debug1: SSH2_MSG_KEX_ECDH_REPLY received  
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A  
debug1: load_hostkeys: fopen /c/Users/dnewey/.ssh/known_hosts2: No such file or directory  
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory  
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory  
debug1: Host 'bitbucket.org' is known and matches the RSA host key.  
debug1: Found key in /c/Users/dnewey/.ssh/known_hosts:2  
debug1: rekey out after 134217728 blocks  
debug1: SSH2_MSG_NEWKEYS sent  
debug1: expecting SSH2_MSG_NEWKEYS  
debug1: SSH2_MSG_NEWKEYS received  
debug1: rekey in after 134217728 blocks  
debug1: Will attempt key: CORP+dnewey@DESKTOP-8PUBBUL RSA SHA256:eELJ6bXbbD2+MrJxhQln6MOb+iiEvxlEfvr7Ixm+kY0 agent  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_rsa RSA SHA256:916Ch30WKDrIXIDvwk+Ooiti7GbndfTKvLGyTq+rcyQ  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_dsa  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_ecdsa  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_ecdsa_sk  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_ed25519  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_ed25519_sk  
debug1: Will attempt key: /c/Users/dnewey/.ssh/id_xmss  
debug1: SSH2_MSG_EXT_INFO received  
debug1: kex_input_ext_info: server-sig-algs=\<rsa-sha2-256,ssh-dss,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-rsa,rsa-sha2-512,ecdsa-sha2-nistp256,ecdsa-sha2-nistp521,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com\>  
debug1: SSH2_MSG_SERVICE_ACCEPT received  
debug1: Authentications that can continue: publickey  
debug1: Next authentication method: publickey  
debug1: Offering public key: CORP+dnewey@DESKTOP-8PUBBUL RSA SHA256:eELJ6bXbbD2+MrJxhQln6MOb+iiEvxlEfvr7Ixm+kY0 agent  
debug1: Server accepts key: CORP+dnewey@DESKTOP-8PUBBUL RSA SHA256:eELJ6bXbbD2+MrJxhQln6MOb+iiEvxlEfvr7Ixm+kY0 agent  
debug1: Authentication succeeded (publickey).  
Authenticated to bitbucket.org (\[104.192.141.1\]:22).  
debug1: channel 0: new \[client-session\]  
debug1: Entering interactive session.  
debug1: pledge: filesystem full  
PTY allocation request failed on channel 0  
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0  
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled  
debug1: channel 0: free: client-session, nchannels 1  
Connection to bitbucket.org closed.  
Transferred: sent 3524, received 2296 bytes, in 0.1 seconds  
Bytes per second: sent 33871.3, received 22068.2  
debug1: Exit status 0

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push origin/develop  
fatal: 'origin/develop' does not appear to be a git repository  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git remote -v  
origin git@bitbucket.org:calixtoemilio/netlytics.git (fetch)  
origin git@bitbucket.org:calixtoemilio/netlytics.git (push)

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git remote -r  
error: unknown switch \`r'  
usage: git remote \[-v \| --verbose\]  
or: git remote add \[-t \<branch\>\] \[-m \<master\>\] \[-f\] \[--tags \| --no-tags\] \[--mirror=\<fetch\|push\>\] \<name\> \<url\>  
or: git remote rename \<old\> \<new\>  
or: git remote remove \<name\>  
or: git remote set-head \<name\> (-a \| --auto \| -d \| --delete \| \<branch\>)  
or: git remote \[-v \| --verbose\] show \[-n\] \<name\>  
or: git remote prune \[-n \| --dry-run\] \<name\>  
or: git remote \[-v \| --verbose\] update \[-p \| --prune\] \[(\<group\> \| \<remote\>)...\]  
or: git remote set-branches \[--add\] \<name\> \<branch\>...  
or: git remote get-url \[--push\] \[--all\] \<name\>  
or: git remote set-url \[--push\] \<name\> \<newurl\> \[\<oldurl\>\]  
or: git remote set-url --add \<name\> \<newurl\>  
or: git remote set-url --delete \<name\> \<url\>

-v, --verbose be verbose; must be placed before a subcommand

<br />

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git branch -r  
origin/HEAD -\> origin/master  
origin/develop  
origin/lytyx_net  
origin/master  
origin/proofOfConcept

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git status  
On branch develop  
Your branch is ahead of 'origin/develop' by 4 commits.  
(use "git push" to publish your local commits)

nothing to commit, working tree clean

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git push  
Enumerating objects: 166, done.  
Counting objects: 100% (166/166), done.  
Delta compression using up to 8 threads  
Compressing objects: 100% (108/108), done.  
Writing objects: 100% (110/110), 30.12 KiB \| 1.16 MiB/s, done.  
Total 110 (delta 67), reused 0 (delta 0), pack-reused 0  
remote: Resolving deltas: 100% (67/67), completed with 38 local objects.  
remote:  
remote: Create pull request for develop:  
remote: [https://bitbucket.org/calixtoemilio/netlytics/pull-requests/new?source=develop\&t=1](https://bitbucket.org/calixtoemilio/netlytics/pull-requests/new?source=develop&t=1)  
remote:  
To bitbucket.org:calixtoemilio/netlytics.git  
bc8333f..6b7d858 develop -\> develop

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$ git status  
On branch develop  
Your branch is up to date with 'origin/develop'.

nothing to commit, working tree clean

CORP+dnewey@DESKTOP-8PUBBUL MINGW64 /c/xampp/htdocs/connectlytix (develop)  
$


Answers:
author: Akshay_miniOrange
body: Hey [@David Newey](/t5/user/viewprofilepage/user-id/4404161)

You can use - "git push origin develop"

Take a note - In a Bitbucket, you separate the "repo" and "branch" names using a space instead of a slash (/).

And the thing the "git push" command worked is because, by default, it considers the branch that you are working on, i.e. the branch that you checkout.

Let's say you have a few commits to be pushed from the "master" branch, but your current branch is a "develop". In that case, simply using a "git push" will not work. You'll have to use "git push origin master".

Hope it helps,

Thanks!

comments: author: David Newey
body: Akshay, thank you for your response. What you say aligns with what I understand to be true, but if you look in the session that I included I did try 'git push origin develop' at one point and that didn't work. So that leaves me still with a question as to whether I am going to go through a whole rigamarole again next time I do a push.


Tags: bitbucket-cloud

cloud