zoukankan      html  css  js  c++  java
  • github入门操作

    一、更新github上的已有项目:

      将repository clone到本地

    shanyu@debian:~/Git$ git clone https://github.com/xunbu7/HelloWorld.git

      添加py.md文件并提交(所有的git命令操作都在HelloWorld目录下,并且一个仓库目录有一个隐藏的.git目录,里面记录了该仓库的服务地址等信息)

    shanyu@debian:~/Git/HelloWorld$ touch py.md
    shanyu@debian:~/Git/HelloWorld$ git status //查看更改 shanyu@debian:
    ~/Git/HelloWorld$ git add py.md shanyu@debian:~/Git/HelloWorld$ git commit -m "py"

      向GitHub推送,完成版本库初始化。

    shanyu@debian:~/Git/HelloWorld$ git push origin master
    //输入的用户名密码为github用户的用户名密码(
    开发者向GitHub版本库写入最常用到的协议是SSH协议,
    //因为SSH协议使用公钥认证,可以实现无口令访问,而若使用HTTPS协议每次身份认证时都需要提供口令.
    //但是,可以通过在文件~/.netrc中写入明文口令实现使用 HTTPS 协议时也能自动完成认证) Username for 'https://github.com': xunbu7@gmail.com Password for 'https://xunbu7@gmail.com@github.com':

     二、本地创建已有版本库的分支

    shanyu@debian:~/Git/gitrepo$ git init
    Initialized empty Git repository in /home/shanyu/Git/gitrepo/.git/
    
    shanyu@debian:~/Git/gitrepo$ touch eig.md
    shanyu@debian:~/Git/gitrepo$ git add eig.md 
    shanyu@debian:~/Git/gitrepo$ git commit -m "eig"
    
    shanyu@debian:~/Git/gitrepo$ git remote add origin git@github.com:xunbu7/Second.git
    
    //shanyu@debian:~/Git/gitrepo$ git push origin master//更新master
    shanyu@debian:~/Git/gitrepo$ git push origin master:mybranch//更新mybranch分支,没有分支,创建分支并更新

    三、ssh公钥配置

    创建本地仓库:(当前路径下生成一个.git目录)
    shanyu@debian:~/Git$ git init
    
    生成ssh密钥(将生成的id_rsa.pub内容复制,添加到主站的sshKey下)
    shanyu@debian:~/Git$ ssh-keygen -t rsa -C "xunbu7@gmail.com"
    
    验证公钥是否有效
    shanyu@debian:~/.ssh$ ssh -T git@github.com
    如果是第一次的会提示是否continue,输入yes就会看到:
    You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。
    
    
    接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。
    shanyu@debian:~/.ssh$ git config --global user.name "xunbu7"
    shanyu@debian:~/.ssh$ git config --global user.email "xunbu7@gmail.com"
  • 相关阅读:
    subprocess模块
    面向对象进阶
    python---面向对象学习
    vim命令---存阅
    python基础-软件目录开发规范
    装饰器、迭代器、生成器
    Python基础类型
    使用Git来撤销修改
    使用Git去管理修改
    了解Git的工作区和暂存区
  • 原文地址:https://www.cnblogs.com/xunbu7/p/5612537.html
Copyright © 2011-2022 走看看