I created a new repo, cloned it, added files to the directory, added them with
add -A, committed changes, and when I try to push using
git push <repo name> master I get:
hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first merge the remote changes (e.g.,
hint: ‘git pull’) before pushing again.
This doesn’t seem to make sense since it’s a new repo and contains only a readme file.
This happens if you initialized a new github repo with
git remote add origin [//your github url] //pull those changes git pull origin master // or optionally, 'git pull origin master --allow-unrelated-histories' if you have initialized repo in github and also committed locally //now, push your work to your new repo git push origin master
Now you will be able to push your repository to github. Basically, you have to merge those new initialized files with your work.
git pull fetches and merges for you. You can also fetch and merge if that suits you.