Reputation: 639
I have created a project and want to push it to git. I have created the repository on git and want to now push my code but I am not able to configure the git. I am getting the following error when I try to run git push -u origin master Error:
fatal: '[email protected]/dearestpankaj:cbb6c2bc8c0ea84120749a745fe59ab5de04d8b6/CoffeeDbApp' 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.
I have added my email and user name with following command:
git config --global user.email "[email protected]"
git config --global user.name "my_git_user_name"
After this I did the following:
git init
git add -A
git commit -m 'my first commit'
git remote add origin [email protected]/my_git_user_name/MyRepositoryName
But with above command I get following error: fatal: remote origin already exists.
git push -u -f origin master
with the above command, I get access right error. I understand that I have to add my password somewhere but I am not able to find where to add it to my terminal. I have now also created a personal token in the GitHub settings but still not sure how to use it. Right now I only have master branch in my remote which is created by default. I want to push in this branch and then, later on, will add more branches for my work.
Edit: I tried to add SSH key but when I still I am not able to push/pull. when I tried git push, I got the following:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
when I tried above command, I got the following error: To github.com:dearestpankaj/CoffeeDbApp.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:dearestpankaj/CoffeeDbApp.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Upvotes: 0
Views: 1107
Reputation: 8348
In addition to adding SSH key as mentioned by Kevin, follow these steps:
git pull origin master --allow-unrelated-histories
git merge origin origin/master
... add and commit here...
git push origin master
Upvotes: 2
Reputation: 445
Here are the steps to push a new codebase that exists on your computer to GitHub:
origin
Git remote from your repository: git remote remove origin
Code
button, select Use SSH
if it's visible, and copy the URL. It should start with [email protected]
origin
Git remote: git remote add origin [paste URL]
(replace [paste URL]
with the URL you just copiedgit push
to push to GitHubUpvotes: 3