The first step
Create a new repository on GitHub and copy the repository address
The second step
- Go to git bash in your project directory
- The input
git init - The input
git add. Add all files - The input
git commit -m 'init'Add to the local repository - The input
Git remote add origin git remote add originAdd a remote host name, origin (or whatever you choose, generally), and the repository address will be your host
The third step
- perform
git pull origin masterSynchronize the code from the Master branch of the Origin host, but at this point you might reportrefusing to merge unrelated historiesThis error
This is because Git finds out that the local repository doesn’t have the same place as your remote repository. It is used to remind you that the two repositories may not be the same repository, and if you do need to commit, do it
git pull origin master --allow-unrelated-historiesAdding this suffix will allow unrelated historical versions to be merged.
The last step
- perform
git push u origin masterUpload the local code to a remote repository, where you can use Git to push the local project to a remote new repository or an existing repository.
Add Git related knowledge
(reference nguyen other teacher’s article www.ruanyifeng.com/blog/2014/0…).
-
Git Clone clones remote code locally
-
Git remote is used to manage host names. A remote host must have a host name
Git remote show Specifies the host nameView host detailsGit remote add git remote addAdding a Remote HostGit remote rm Host nameDeleting a Remote HostGit remote rename Specifies the new host nameRename the host name
-
Git fetch fetch fetch git fetch fetch git fetch fetch git fetch fetch git fetch fetch git fetch
-
Git pull fetch the update from the remote host and merge it with the current development code. Git pull Remote host name Remote branch name: Local branch name Pull the update from the remote host and merge it with the local branch
-
Git push commits local code to a remote repository in much the same way git pull commits local code to a remote repository and git pull synchronizes remote code to a local repository