Uploading local code to gitHub and its problems

I wrote a small H5 game locally before, and I always wanted to upload it to gitHub. I finally did it today.

First, download git:

 

Find out if your computer is 32-bit or 64-bit

Open cmd and enter the file to be uploaded to github,

bigfish_smallfish (object file) is a complete program that I want to upload to github

Then, use the git init command to create the repository;

Then use git add * to upload all the files in the target file to the git staging area at one time,

Use the git commit -m "........" command to store the contents of the temporary storage area in the warehouse. The "" is the analysis of the uploaded content. 

In this way, all the content in the target file will be stored in the local warehouse

 

Next, in the target file, right-click to open, select

 

Use git remote add origin [path], path is the repository I have created on github before

 

path is available here:

 

 But after I enter the command, the error of remote origin already exists is reported

At this point we can delete the remote warehouse first: git remote rm origin 

Then re-add: git remote add origin [path], then enter:  git push -u origin master

However, the error of master -> master (fetch first) was reported at this time,

 

After I entered the git pull origin master command, I reported the error of refusing to merge unrelated histories. This is because when I uploaded the code for the first time, the remote branch was different from the local branch. When the remote repository was created, there was a README.md file. , but not in the local repository, so I want to push him to prompt you to pull it first. You pull it, and he prompts you again: fatal: refusing to merge unrelated histories

At this point we can:

先git log -p master..origin/master View the difference between the local master branch and the remote (origin) branch;

Then git pull --rebase origin master this command will generate a README.md file locally and pull down the remote code.

Last git push -u origin master upload code

Refresh github and you will see the target files we uploaded in the past

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324777612&siteId=291194637