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 inputgit init
  • The inputgit add. Add all files
  • The inputgit commit -m 'init'Add to the local repository
  • The inputGit 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

  • performgit 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 itgit pull origin master --allow-unrelated-historiesAdding this suffix will allow unrelated historical versions to be merged.

The last step

  • performgit 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

    1. Git remote show Specifies the host nameView host details
    2. Git remote add git remote addAdding a Remote Host
    3. Git remote rm Host nameDeleting a Remote Host
    4. Git 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