I have created a bare repo (/Volumes/500gb/myproject.git
).
I have added the bare repo to my working directory /Volumes/500gb/test1
.
I have created the branches as follows:
# git branch
master
test1
* test2
I have created a file in branch test2
and committed.
when I try to push to test2
branch, I am getting the following errors:
# git push origin master
To /Volumes/500gb/myproject.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '/Volumes/500gb/myproject.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
When I try to pull from master
, I am getting following errors. But I could merge the test2
branch from master
.
# git pull master
fatal: 'master' 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.
Someone, please clarify the issue. Thanks.
(Part of) the syntax for git pull is git pull <repository> <refspec>
.
In your case, when you call git pull master
, git thinks you want to pull the current branch state from a repository named master
.
So instead, just type git pull
if you're on master, or git pull origin master
to be more precise.
Source: https://git-scm.com/docs/git-pull
Your first question should be easier to solve once you can pull and update your local repository state.