Jackson
Jackson

Reputation: 1526

Git switch file from one to another: Can't push

On dev I have 2 branches

 $ git  branch
   dev *
   master

I have copied file from dev to master branch by doing

 $ git checkout master
 $ git checkout dev <file path>

When I'm trying to commit that file

root@magento:~/abc.sg/magento# git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Then

root@magento:~/abc.sg/magento# git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

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

When i run log to see then it says

*   4b471cd - (10 minutes ago) WIP on master: b937e71 Text - Text (refs/stash)

I'm logged in as root

Upvotes: 0

Views: 90

Answers (2)

LeGEC
LeGEC

Reputation: 51880

The error message displays 2 informations :

  1. the first one is a lengthy warning about options for the push command
  2. the second one says "permission denied", and is the actual reason why your push does not succeed

To fix 1. :
you probably want to use the simple option by default. Type once in your terminal :

git config --global push.default simple

and this lengthy warning should go away.
(for more information, you can read the detailed description in git help push)

To fix 2. :
you say you are logged in as root, so you are probably not using the right ssh key. If you know that you uploaded and installed the public key for your personal account on the remote server, try running git push from your personal account.

Upvotes: 1

Anas Laghouaouta
Anas Laghouaouta

Reputation: 105

seems like you have a permission issue, to be sur try to use HTTPS URL instead of the SSH URL to avoid dealing with the SSH public key authentification.
to do so, you need to modify the config file in .git/config by setting the
[remote "origin"] url = <ssh remote>
by

[remote "origin"]
   url = https://<https remote>  

and then try a simple

git push origin master

Upvotes: 0

Related Questions