How do I pull my project from github?

后端 未结 6 901
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 19:39

I have a project on github that I have been working on before. However, I wiped out my computer and I am wondering which git command should I invoke under my username to checko

相关标签:
6条回答
  • 2021-01-29 19:52

    Run these commands:

    cd /pathToYourLocalProjectFolder
    
    git pull origin master
    
    0 讨论(0)
  • 2021-01-29 19:54

    There are few steps to be followed (For Windows)

    1. Open Git Bash and generate ssh key Paste the text below, substituting in your GitHub email address.

      ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

      This creates a new ssh key, using the provided email as a label.

      Generating public/private rsa key pair.

      When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

      Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]

      At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".

      Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]

    2. Add the key to SSH Agent

      Type the following in Git Bash (99999 is just an example) to see agent is up and running. eval $(ssh-agent -s) Agent pid 99999

      then type this.

      ssh-add ~/.ssh/id_rsa

      then Copy the SSH key to your clipboard using this command

      clip < ~/.ssh/id_rsa.pub

    3. Add the SSH Key to the Git Account

      In GitHib site, click on the image on top right corner, and select settings. In the subsequent page, click SSH and GPG keys option. This will open up the SSH key page. Click on the New SSH key. In the "Title" field, add a descriptive label for the new key. Paste your key into the "Key" field.

    4. Clone the Repository

      Open VS Code (or any IDE/CLI which has command prompt etc.). Go to the directory in which you want to clone, using cd commands, and type the below line. git config --global github.user yourGitUserName git config --global user.email your_email git clone git@github.com:yourGitUserName/YourRepoName.git

    https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

    0 讨论(0)
  • 2021-01-29 20:08

    Git clone is the command you're looking for:

    git clone git@github.com:username/repo.git
    

    Update: And this is the official guide: https://help.github.com/articles/fork-a-repo

    Take a look at: https://help.github.com/

    It has really useful content

    0 讨论(0)
  • 2021-01-29 20:15

    First, you'll need to tell git about yourself. Get your username and token together from your settings page.

    Then run:

    git config --global github.user YOUR_USERNAME
    git config --global github.token YOURTOKEN
    

    You will need to generate a new key if you don't have a back-up of your key.

    Then you should be able to run:

    git clone git@github.com:YOUR_USERNAME/YOUR_PROJECT.git
    
    0 讨论(0)
  • 2021-01-29 20:17

    You Can do by Two ways,

    1. Cloning the Remote Repo to your Local host

    example: git clone https://github.com/user-name/repository.git

    2. Pulling the Remote Repo to your Local host

    First you have to create a git local repo by,

    example: git init or git init repo-name then, git pull https://github.com/user-name/repository.git

    That's all, All commits and branch in the remote repo now available in the local repository of your computer.

    Happy Coding, cheers -:)

    0 讨论(0)
  • 2021-01-29 20:19

    Since you have wiped out your computer and want to checkout your project again, you could start by doing the below initial settings:

    git config --global user.name "Your Name"
    git config --global user.email youremail@domain.com
    

    Login to your github account, go to the repository you want to clone, and copy the URL under "Clone with HTTPS".

    You can clone the remote repository by using HTTPS, even if you had setup SSH the last time:

    git clone https://github.com/username/repo-name.git
    

    NOTE:

    If you had setup SSH for your remote repository previously, you will have to add that key to the known hosts ssh file on your PC; if you don't and try to do git clone git@github.com:username/repo-name.git, you will see an error similar to the one below:

    Cloning into 'repo-name'...
    The authenticity of host 'github.com (192.30.255.112)' can't be established.
    RSA key fingerprint is SHA256:nThbg6kXDoJWGl7E1IGOCspZomTxdCARLviMw6E5SY8.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    Using HTTPS is a easier than SSH in this case.

    0 讨论(0)
提交回复
热议问题