Git Providing first error when trying to click

I have my first acquaintance with git through a class that I accept. I have several files in a directory on my computer and I can create and transfer them without problems. However, when I try to transfer files to my github repository, I keep getting this message:

Pushing to https://github.com/BigMeanCat/CMDA To https://github.com/BigMeanCat/CMDA ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/BigMeanCat/CMDA' 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: (eg, 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

Can someone help me what it means and how to fix it? I saw several people with similar problems on the Internet, but I NEEDED git and was not good enough at the git command line language. I do not dare to accept certain proposals, as I do not know whether he will solve the problem or aggravate it.

Thanks!

+6
source share
7 answers

Someone else (or you on some other machine) pushed a set of changes to a remote repository. You do not have these changes on your local machine yet. Therefore, to solve the situation, you first need to

 git pull 

and then

 git push 

However, you cannot git pull while you have the changes in the working tree, so before you click / pull, you must first commit or stash to change your local changes. This could potentially cause a merge situation if the remote changes match your local ones.

+12
source

I got the same error, then solved this topic with the "-force" command. In short, write this command:

 git push origin master --force 

Caution: you may have tried to repeat your codes again and again, so you accepted this error. My solution is much in correspondence with your set of changes. Through this method, your repository can lead to other people's inconsistencies. But if you work on your own (not as a group working), you can easily use "-force", as I mentioned above.

+7
source

This means that someone clicked on a job in a remote repository to combine it with your work, which you can run git pull --rebase , then move your collaboration back to the remote repository.

+2
source

You can solve the problem with the team.

 git push origin master --force 
+2
source

@tunacy said it was good.

someone made a repository, so you just need to do

 git pull 

and

 git push 

that all of you can also use

 git merge 

to merge

+1
source

When you get started with git, you can take a look at the documentation: http://git-scm.com/doc . From your description, I understand that you have an existing repository with files that are shared with other classmates. Therefore, you need to first pull out the entire project (with all the files). Having an updated version of the project in your local repository, you can click commit changes to the repository.

0
source

git pull is a good option

But also: git the push origin master --force command will ultimately help if the problem persists

0
source

Source: https://habr.com/ru/post/975341/


All Articles