-1

new to git,just create new repo on github for a project i locally made.After git init,git add and commit all files,add remote,finally trying to push "git push origin main" my project on github,gives me an error

error: failed to push some refs to 'https://github.com/sam97/test.git'
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.

i did these with terminal to learn using it

Guildenstern
  • 2,179
  • 1
  • 17
  • 39
dev_sam
  • 1
  • 1
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+remote+contains+work+that+you+do+not+have+locally – phd Aug 07 '23 at 12:47

1 Answers1

0

Hello assumimg that you executed all commands you should,you probably have created a readme file (or maybe another file or made changes) , when you first create your repo on github and terminal says that there have been changes on remote you don't have locally.

"The tip of your current branch is behind its remote counterpart"

Git tells you to import new changes from REMOTE (github) and merge it with your code (local) and then push it to remote. Try to pull those files on your local machine git pull --rebase origin main and then git push origin main your project.Ask again if you are confused.