1. 程式人生 > >新機git簡單配置

新機git簡單配置

edit pbo -s with add min lte which upper

新機git簡單配置,畢竟不常用,不用每次都查
1、安裝git
windows:https://git-scm.com/download/win
ubuntu: apt install git

2、全局配置

git config --global user.name "you_name"
git config --global user.email "[email protected]"


3、生成ssh-key
ssh-keygen -t rsa -b 4096 -C "[email protected]"

4、添加ssh到github 以後不用每次都輸入郵箱及密碼
cat ~/.ssh/id_rsa.pub
把輸出的內容拷貝到github上
github 在https://github.com/settings/keys
點擊左上角 New SSH key 把剛才的內容復制到下面的框裏,點擊Add SSH key

5、可以clone你自己的代碼 然後修改提交了

參考:

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

  1. Open Terminal.

  2. Paste the text below, substituting in your GitHub email address.

    ssh-keygen -t rsa -b 4096 -C "[email protected]"
    

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

    Generating public/private rsa key pair.
    
  3. 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 (/home/you/.ssh/id_rsa): [Press enter]
    
  4. 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]

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

Note: DSA keys were deprecated in OpenSSH 7.0. If your operating system uses OpenSSH, you‘ll need to use an alternate type of key when setting up SSH, such as an RSA key. For instance, if your operating system is MacOS Sierra, you can set up SSH using an RSA key.

  1. Copy the SSH key to your clipboard.

    If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don‘t add any newlines or whitespace.

    $ sudo apt-get install xclip
    # Downloads and installs xclip. If you don‘t have `apt-get`, you might need to use another installer (like `yum`)
    
    $ xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    

    Tip: If xclip isn‘t working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  2. 技術分享In the upper-right corner of any page, click your profile photo, then click Settings.

  3. 技術分享In the user settings sidebar, click SSH and GPG keys.

  4. 技術分享Click New SSH key or Add SSH key.

  5. In the "Title" field, add a descriptive label for the new key. For example, if you‘re using a personal Mac, you might call this key "Personal MacBook Air".
  6. 技術分享Paste your key into the "Key" field.
  7. 技術分享Click Add SSH key.
  8. 技術分享If prompted, confirm your GitHub password.

新機git簡單配置