zoukankan      html  css  js  c++  java
  • Ubuntu下GitHub的使用

    Ubuntu下GitHub的使用参考

    http://www.pythoner.com/263.html
    0.Git安装
    执行如下命令安装Git,所有依赖包会自动安装:
    $ sudo apt-get install git


    1.注册GitHub,创建版本库

    https://help.github.com/articles/generating-ssh-keys/

    2.检查SSH
    因为GitHub会用到SSH,因此需要在shell里检查是否可以连接到GitHub:
    $ ssh -T git@github.com
    如果看到:
    Warning: Permanently added ‘github.com,204.232.175.90′ (RSA) to the list of known hosts.
    Permission denied (publickey).
    则说明可以连接。


    3.创建本地SSH密钥
    检查~/.ssh目录下是否有id_rsa(私钥)和id_rsa.pub(公钥)文件,如果有,则备份出来,删除原文件,再执行如下语句;否则直接执行如下语句:
    $ ssh-keygen -t rsa -C "user@mail.com"


    4.GitHub中设置公钥
    在GitHub中,依次点击Account settings(右上角倒数第二个图标) -> SSH Keys -> Add SSH Key,将id_rsa.pub文件中的字符串复制进去。
    再次检查SSH连接情况:
    $ ssh -T git@github.com
    如果看到如下所示,则表示添加成功:
    Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.

    5.配置与初始化

    http://gitbook.liuhui998.com/2_2.html
    Git 配置
    使用Git的第一件事就是设置你的名字和email,这些就是你在提交commit时的签名。
    $ git config --global user.name "Scott Chacon"
    $ git config --global user.email "schacon@gmail.com"
    执行了上面的命令后,会在你的主目录(home directory)建立一个叫 ~/.gitconfig 的文件. 内容一般像下面这样:
    [user]
            name = Scott Chacon
            email = schacon@gmail.com
    译者注:这样的设置是全局设置,会影响此用户建立的每个项目.如果你想使项目里的某个值与前面的全局设置有区别(例如把私人邮箱地址改为工作邮箱);你可以在项目中使用git config 命令不带 --global 选项来设置. 这会在你项目目录下的 .git/config 文件增加一节[user]内容(如上所示).


    6.GitHub创建时提供的初始化repository的方法
    echo "# repo name" >> README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/username/repository.git
    git push -u origin master

    7.clone来自GitHub的项目
    可以用如下方式将GitHub远程版本库中的代码clone到本地:
    $ git clone git@github.com:username/test.git
    $ git clone git://github.com/username/test.git
    [GitHub]fatal:remote error解决办法:

    http://blog.csdn.net/xsckernel/article/details/9015367

    8.Github使用指南,两分钟了解GitHub的基本思想

    http://rogerdudler.github.io/git-guide/index.zh.html


    9.开始工作:常用的Git命令
    git init # 初始化本地Git版本库
    git add # 暂存文件,如果使用.表示当前目录及其子目录
    git commit -m “first commit” # 提交,-m选项后跟内容为提交所用的注释
    git remote -v # 查看当前项目远程连接的是哪个版本库地址
    git push origin master # 将本地项目提交到远程版本库
    git fetch origin # 取得远程更新(到origin/master),但还没有合并
    git merge origin/master # 把更新的内容(origin/master)合并到本地分支(master)
    git pull origin master # 相当于fetch和merge的合并,但分步操作更保险

    10.快速使用指南

    http://html5beta.com/misc/the-github-quick-guide/

     

    11.git删除文件和文件夹

    http://blog.csdn.net/jrainbow/article/details/16858547

    删除分支

    git branch -a

    git push origin --delete xxx

    删除文件夹

    ls

    git rm xxx -r -f

    git commit -m "delete xxx"

    git push origin master

    12.git移动操作

    http://www.yiibai.com/git/git_move_operation.html

    [tom@CentOS project]$ pwd
    /home/tom/project
    
    [tom@CentOS project]$ ls
    README string string.c
    
    [tom@CentOS project]$ mkdir src
    
    [tom@CentOS project]$ git mv string.c src/
    
    [tom@CentOS project]$ git status -s
    R string.c −> src/string.c
    ?? string

     

  • 相关阅读:
    Js原型对象理解
    Garbage In Garbage Out
    JournalNode的作用
    SecondaryNameNode 的作用
    Hive Map数据长尾问题
    Hive基本操作
    Hadoop中NameNode的工作机制
    技术架构分析与架构分析
    Sqoop报错Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
    项目管理PMP相关
  • 原文地址:https://www.cnblogs.com/daijkstra/p/4402919.html
Copyright © 2011-2022 走看看