-1

Firstly I commited with master branch now I am in main branch and unable to change to master branch. Moreover if I tried to commit to my repo through main branch the following errors it shows:-

$ git push --set-upstream https://github.com/manvith22/Evernote-clone.git main

To https://github.com/manvith22/Evernote-clone.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/manvith22/Evernote-clone.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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

abc@MA MINGW64 ~/react-redux-hooks (main)
    $ git pull <remote> master:dev
bash: remote: No such file or directory

abc@MA MINGW64 ~/react-redux-hooks (main)

    $ git pull <main> master:dev

bash: main: No such file or directory

abc@MA MINGW64 ~/react-redux-hooks (main)

    $ git pull <evernote> master:dev

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=<remote>/<branch> main
IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • It is `main`, not `master`. – dan1st Jun 16 '21 at 13:17
  • 2
    This is an extremely common question. Please see https://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to-remote or https://stackoverflow.com/questions/39399804/updates-were-rejected-because-the-tip-of-your-current-branch-is-behind-its-remot or https://stackoverflow.com/questions/4684352/what-does-git-push-non-fast-forward-updates-were-rejected-mean or https://stackoverflow.com/questions/9794413/failed-to-push-some-refs-to-githeroku-com or https://stackoverflow.com/questions/9832348/git-push-rejected-error-failed-to-push-some-refs or many others... – IMSoP Jun 16 '21 at 13:19
  • https://www.biteinteractive.com/of-git-and-github-master-and-main/ – matt Jun 16 '21 at 13:21
  • 1
    Also, an important point of terminology: you _commit_ changes in your local repository. The commands you show are when you're *pushing* the work you've already committed - that is, *sharing* or *synchronizing* it with a remote server. Understanding the difference will be very important when you're learning about how to use git. – IMSoP Jun 16 '21 at 13:22

2 Answers2

1

The </> brackets mean it's a placeholder for whichever branch you really mean. You don't need to type the brackets out; you just want

git pull https://github.com/manvith22/Evernote-clone.git main

or most likely just

git pull

will do.

However, looking at the repository https://github.com/manvith22/Evernote-clone there are two branches; master and main. You'll need to talk with the other people working on the repo to choose which branch you'll be using.

AKX
  • 152,115
  • 15
  • 115
  • 172
0

There is a mismatch between what is committed on origin and your local, thus the first push failed.

You can bring change from remote using git pull --rebase (assuming you are already on main branch)

After that you can push you changes with git push command.

PS: using < is used for providing input from file and > to write output to file. By running git pull <remote> master:dev you are saying, read from file remote and write output to file master:dev

Ahzaz
  • 88
  • 6