I cannot publish my VS Code repository to GitHUB


I have a project in my windows laptop and I’m using MS Visual Studio Code.

I installed git on windows, addded a repository and commited my code.

Created a repository on GitHUB and added to my local with this command:

git remote add Codeigniter-starter-kit https://github.com/rostamiani/Codeigniter-starter-kit

Now when I try to publish branc, this error comes up:

> git push -u Codeigniter-starter-kit master
To https://github.com/rostamiani/Codeigniter-starter-kit
 ! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/rostamiani/Codeigniter-starter-kit'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

There is just a readme in the remote. I tried to pull it and this time this is the error:

> git pull --tags
> git show :application/controllers/Test.php
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=Codeigniter-starter-kit/<branch> master
> git show :application/controllers/Test.php
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
fatal: no upstream configured for branch 'master'
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose

What’s wrong?

Hi @rostamiani,

It sounds like you currently have two repositories with no common history which you are trying to merge together, is that correct? If you want to keep all of the Git history that you have in your local project since there’s only a README file in your remote repository, I’d recommend setting up a new remote repository with nothing in it and pushing your local repository to that project.

Otherwise, you could have the remote repository on one branch, your local project on another branch, and then work on merging those two together before pushing up your project.


1 Like