0

I am a newbie and trying to using Gitbash to push a code to github. When I use the command

git init

it shows me the error

Reinitialized existing Git repository in C:/User/User/Desktop/xxx.git

Then, when I use the command

git add . it is ok

when I use the command

git commit -m "First commit" it shows me this error

On branch master Your branch is ahead of 'origin/master' by 1 commits Nothing to commit, working tree clean

And final, when I try to use those command

git remote add origin https://github.com/xxx/xxx.git git push origin master

It told me that error: failed to push some refs to https://github.com/xxx/xxx.git

I am very confusing because of this error, could you please help me ? Thank you very much.

nguyencuc2186
  • 21
  • 1
  • 6
  • Wrong category my friend, please post this one as `git` related, you will get the answer – Thang Nov 24 '19 at 06:05
  • You forgot to mention the start: was this a `rails new`, or did you do `git clone`? Your errors seem to suggest this folder was a clone, and thus a `origin/master` was already defined. – nathanvda Nov 24 '19 at 07:29
  • Most outputs are actually errors but infos. The only error occurs on `git push`. – dan1st Nov 24 '19 at 08:17
  • Thanks all of you for your comments. I solved my problem by undo `git init`, and eveything seemed ok. https://stackoverflow.com/questions/3212459/is-there-a-command-to-undo-git-init – nguyencuc2186 Nov 24 '19 at 08:32

2 Answers2

3

Please try this to solve the above problem

$ rm -rf .git 

After this command, use:

$ git init 
David
  • 1,192
  • 5
  • 13
  • 30
monika
  • 31
  • 2
0

I have the same problem but I fixed it so just use $ git add . to add all files from your directory

Abdulrahman
  • 775
  • 6
  • 19