zoukankan      html  css  js  c++  java
  • git使用入门

    在github.com上 建立了一个小项目,可是在每次push  的时候,都要输入用户名和密码,很是麻烦

    原因是使用了https方式 push

    在termail里边 输入  git remote -v 

    可以看到形如一下的返回结果

    origin https://github.com/yuquan0821/demo.git (fetch)

    origin https://github.com/yuquan0821/demo.git (push)

    下面把它换成ssh方式的。

     

    1. git remote rm origin
    2. git remote add origin git@github.com:yuquan0821/demo.git

    Create a new repository on the command line

    touch README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/sunnynut/ztgentle.git
    git push -u origin master

    Push an existing repository from the command line

    git remote add origin https://github.com/sunnynut/ztgentle.git
    git push -u origin master

    设置SSH

    如果要跟GitLab服务器打交道,还要设ssh。

    在Linux的命令行下,或Windos上Git Bash命令行窗口中(总之不要用iOS),键入:

    ssh-keygen -t rsa -C "wukong.sun@xxx.com"
    

    然后一路回车。生成ssh key pair。

    如果在Linux上,需要把其中的私钥告诉本地系统:

    ssh-add ~/.ssh/id_rsa
    

    再把其中公钥的内容复制到GitLab上。具体方法是:
    显示ssh公钥的内容:

    cat ~/.ssh/id_rsa.pub
    

    打开GitLab网页,点击“Add SSH Key”,然后把刚才ssh公钥id_rsa.pub的内容paste进去。

    要是GitLab报“不是有效的key”之类的错误,可能是你没去除注意去除多余的回车符,也可能是paste之前copy的时候,没copy最开头的“ssh-rsa ”这几个字。

     
  • 相关阅读:
    defineProperty的使用
    js题库全集
    如何将多个文件夹中的文件合并到一个文件夹中
    CYQ.Data V5 MDataTable 专属篇介绍
    读取和写入配置文件内容的方法
    面对代码中过多的if...else的解决方法
    SQL语句--删除掉重复项只保留一条
    获取当前时间
    Stopwatch 类用于计算程序运行时间
    正则表达式手册
  • 原文地址:https://www.cnblogs.com/ztgentle/p/3782050.html
Copyright © 2011-2022 走看看