-4

I have a repo and I'd like to push to the develop branch.

I have used

$ git checkout develop
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.

And also done git pull of the develop branch.

I expect

$ git push

To push to the develop branch. But that isn't what's happening.

djave at djave-comp in ~/projects/project on develop*
$ git push
Counting objects: 49, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (49/49), 25.45 KiB | 0 bytes/s, done.
Total 49 (delta 38), reused 0 (delta 0)
To bitbucket.org:djave/project.git
   f311657..16b42c7  develop -> develop
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'djave@bitbucket.org:djave/project.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.

It looks like it is pushing to develop:

   f311657..16b42c7  develop -> develop

But then is also trying to push to the master branch (and fails):

 ! [rejected]        master -> master (non-fast-forward)

I expect it to just push to the develop branch and be successful.

How can I make git push just push to the develop branch?

Sorry if this is a duplicate (have searched extensively but can't find the right combination of issues) or the title doesn't use the correct terminology (feel free to update the title)

Djave
  • 8,595
  • 8
  • 70
  • 124

1 Answers1

0

Dont use git push alone, the command can have parameter :

git push <remote_alias> <branch_name>

So in your case you can use :

git push origin develop
Léo R.
  • 2,620
  • 1
  • 10
  • 22
  • This may be a silly question. Is there a way to say "When I am on a branch and use git push, only push to this branch"? – Djave Jan 12 '18 at 13:05
  • Ah maybe `git push origin HEAD` – Djave Jan 12 '18 at 13:07
  • @Djave you can use a config for this, see here: https://stackoverflow.com/questions/21839651/git-what-is-the-difference-between-push-default-matching-and-simple – Tom Jan 12 '18 at 13:43