I\'m trying to push one of my projects to github, and I keep getting this error:
peeplesoft@jane3:~/846156 (master) $ git push
fatal: The current branch mas
You fixed the push, but, independently of that push issue (which I explained in "Why do I need to explicitly push a new branch?": git push -u origin master
or git push -u origin --all
), you need now to resolve the authentication issue.
That depends on your url (ssh as in 'git@github.com/yourRepo
, or https as in https://github.com/You/YourRepo
)
For https url:
If your account is protected by the two-factor authentication, your regular password won't work (for https url), as explained here or here.
Same problem if your password contains special character (as in this answer)
If https doesn't work (because you don't want to generate a secondary key, a PAT: personal Access Token), then you can switch to ssh, as I have shown here.
As noted by qwerty in the comments, you can automatically create the branch of same name on the remote with:
git push -u origin head
Why?
.git\HEAD
file) has the refspec of the currently checked out branch (for example: ref: refs/heads/master
)Since the refpec used for this push is head: (no destination), a missing :<dst>
means to update the same ref as the <src>
(head, which is a branch).
That won't work if HEAD is detached though.
1. A computer and your github associated. Use SSH. Computer code so you do not need to submit verified enter image description here
2. git can not manage empty folder. So you have to write such a readme.md saved in a file. Otherwise you will not find the file.
3. Your local project is nothing new projects move over. Please
git init
git remote add origin +"githublink"
git add .
git commit -m ""
go again.
4. then git pull origin master
(the key)
5. At last git push origin master
(solve all problem).
http://my.oschina.net/psuyun/blog/123005 参考链接
I had the same problem, the cause was that I forgot to specify the branch
git push myorigin feature/23082018_my-feature_eb
If you constantly get the following git error message after attempting a git push with a new local branch:
fatal: The current branch has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin <branchname>
Then the issue is that you have not configured git to always create new branches on the remote from local ones.
The permanent fix if you always want to just create that new branch on the remote to mirror and track your local branch is:
git config --global push.default current
Now you can git push without any errors!
https://vancelucas.com/blog/how-to-fix-git-fatal-the-current-branch-has-no-upstream-branch/
I made the simple error of forgetting to commit:
git commit -m "first commit"
then git push origin master
worked.
If you are trying to push your code direct to the master branch then use command
git push origin master
It helps me.