0

I have remote repository with 2 branches, master and login. I want to push local changes to login branch but it's not working.

$ git push origin/login

fatal: 'origin/login' 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.

It says 'origin/login' does not appear to be a git repository, but I have. What's my problem?

$ git log

commit f385d950a1f8c6412d91b26d749282d1a3ead27a (HEAD -> upstream, login, develop)
Author: SoojungChae <naan_ace@naver.com>
Date:   Sat Nov 3 06:49:16 2018 +0900

    Edit login logic

commit 6719685fbc7f895a909e2515753c02794591595e (origin/login)
Author: SoojungChae <naan_ace@naver.com>
Date:   Sat Sep 22 23:43:57 2018 +0900

    Block unnecessary things

...
SooJungChae
  • 219
  • 1
  • 4
  • 16
  • 1
    Possible duplicate of [How do you create a remote Git branch?](https://stackoverflow.com/questions/1519006/how-do-you-create-a-remote-git-branch) – Felix Nov 02 '18 at 22:30

2 Answers2

1

git push takes two additional arguments:

  • the name of a remote, such as origin
  • the name of a branch, such as master or login

That is, you want:

git push origin login

It's important to keep these two concepts separate: a remote like origin is a short name that you and Git use to keep track of a longer name like https://github.com/some/repo.git or ssh://git@github.com/some/repo.git, which is completely different from a branch name.

What makes this confusing is that besides these concepts and terms—remote and branch—there is a third concept, described by a another sequence of words, usually written as remote-tracking branch.1 This third concept involves strings of the form origin/master and origin/login. It can become very confusing as to when you should write origin login and when you should write origin/login.

The trick would be to consult the documentation, and keep close track of whether it says remote or branch. Unfortunately, the documentation uses neither of those terms, because those are actually special cases of even-more general form. So the documentation (now, Git 2.192) says:

git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose] [-u | --set-upstream] [-o <string> | --push-option=<string>] [--[no-]signed|--signed=(true|false|if-asked)] [--force-with-lease[=<refname>[:<expect>]]] [--no-verify] [<repository> [<refspec>...]]

and the two arguments I am talking about here are called the repository and the refspec, rather than the remote and the branch. How one is supposed to get through all of that, as a beginner, is not at all clear.

(This is a long-winded way of saying that the Git documentation is not so great.)


1I prefer the term remote-tracking name now, because while it has some of the aspects of a branch name, it also has some that are different. Either way, though, this third concept takes the form shown above.

2Older versions of git push have fewer optional arguments.

torek
  • 448,244
  • 59
  • 642
  • 775
0

It looks like you're using the wrong syntax to push. git push takes a URL, path, or remote as its first argument, and then branches come after that. So you'd want to type git push origin login if you wanted to push your current login branch to the login branch on origin.

bk2204
  • 64,793
  • 6
  • 84
  • 100