linux git使用github

1. git安装

2. 着重记录下如何配置才能正常使用github

  2.1 生成ssh-rsa

    ssh-keygen -t rsa -C  "your email"

    然后在~/.ssh/生成id_rsa.pub和id_rsa两个文件,(如果这俩已经存在,建议备份在其他目录先

  2.2 配置github帐号

    git config --global user.name "abc"

    git config --global user.email "abc@gmail.com"

    配置github上的SSH keys(account setting)

    将id_rsa.pub里面的内容完全copy到Key的文本域,保存即可

  2.3 cmd使用ssh -T git@github.com会输出 “Hi Daniel-ccx! You've successfully authenticated, but GitHub does not provide shell access”

  2.4 创建一个项目目录 test,执行git init,git remote add origin git@github.com:你github显示名称/test.git(这个命令只是指定你的远程项目,所以在此之前你得在github创建 New Repository)。设置错了可以用这个命令修改:git remote set-url origin git@github.com:你github显示名称/test.git

  2.5 执行git pull origin master,将github上的文件down到工作目录

  2.6 vim hello.go然后提交到github上,git add hello.go(本地git库) git commit -m "add hello file" 然后git push origin master 到github库

3. 检测本地版本

    git branch

  检测git服务器branch

    git branch -r

      origin/HEAD -> origin/master
      origin/beta1.0
      origin/beta1.1
      origin/master
      origin/v1.0

4. 切换到其他版本(origin/v1.0)

  git checkout v1.0  #检出v1.0并切换工作目录到v1.0

  git checkout master #切换到master

    

5. 下载branch 版本

  git pull __GITURL__ v1.0  

    

6. 提交到branch

7. 设置开发者信息

  git config --global user.name="Daniel"

  git config --global user.email="daniel@bbs.com"

  git config --global color.uid="always"

原文地址:https://www.cnblogs.com/the-moving-ear/p/3478189.html