Git remote repository operation notes

  • This note is mainly for Github to write a related remote operation notes, also related SSH key generation and use operations.

Connecting a remote warehouse

  • I need to operate on Git’s remote repository, which WILL be my MyStudyNotes repository
    • The first step is to go into the local repository where we need to establish a connection and execute the following code
      • git remote add origin https://github.com/china-renqing/MyStudyNotes.git
      • When you’re done, tell your local Git repository, and subsequent operations will automatically connect to the specified address

The simplest remote warehouse operation

  • Commit to the remote repository

    • git push -u origin master
      • The code change means that the action will be committed to the master branch of the remote repository, and future Git pushes will be automatically committed to the master branch.
      • The master can be changed to another branch and can be committed to another branch later.
  • Clone the project locally

    • git clone https://github.com/china-renqing/MyStudyNotes.git
  • Clone the specified branch locally (clone the master branch here)

    • git clone -b master https://github.com/china-renqing/learn-MVC.git
  • Pull items to local

    • git pull// Execute this code
  • Delete the branch of the remote repository

    • Delete branch1 (branch1) locallygit branch -d branch1Execute after)git push origin:branch1I can delete branch 1.
  • Push labels to remote repositories

    • Push a specific label to the local repository:Git push origin v0.2
    • Push all tags to local repository:git push origin --tag
  • Delete the label for the remote repository

    • Delete the specified label:Git push origin: ref/tags/v0.2

Using SSH Keys

  • Start by generating an SSH key on your own computer
    • ssh-keygen -t rsa -C "[email protected]"// Follow your email address
    • Open the id_rsa.pub file in C:\Users\YourName\. SSH by default.
  • Add the obtained public key to GitHub corresponding to add SSH key after adding, as shown below: *
  • Check whether the connection is successful
  • Note that after the connection is successfully detected, it is also necessary to tell the local warehouse which warehouse is connected before subsequent operations can be performed
    • Example:git remote add origin https://github.com/china-renqing/MyStudyNotes.git

The future patching

  • If there is any wrong place, I hope you put forward, thank you.