Error:
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/Annedrew/Scripts.git'
hint: Updates were rejected because the remote contains work that you dohint: 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.
Solution :
1. Start by fetching the changes from the remote repository, and merge it into local repository.
git fetch origin main
git merge origin main
2. Open the files that have conflicts in a text editor, and locate the conflicting sections in the file, such as:
<<<<<<< HEAD
Your changes
=======
Remote changes
>>>>>>> branch-name
3. Resolving the conflicts, save the file.
4. Add the resolved files to the staging area.
git add <file name>
5. Commit the changes to complete the merge.
(If there are multiple conflicted files, repeat steps 2-5 for each file.)
git commit -m "merge remote changes"
6. Push your changes to the remote repository.
git push origin <branch-name>
网友评论