GitHub

作者: Cheer_up | 来源:发表于2020-06-29 15:19 被阅读0次

记录利用Git操作github的操作。

git --config -global user.name <your github user name> #配置用户信息
git --config -global user.email <your github email> #配置用户信息
git init <name> #name是可选的。有name表示在当前文件夹建立一个名为name的repository。没有那么表示将当前文件设为repository。
git status #查看本地repository中包含的文件
git add filename #建立连接
git status #这次可以发现和上次不一样了
git commit -m "message" 
git remote add origin ADDR
git -u push origin master #master 是repository的默认分支,若远程repository为空的话,要-u
git push origin master #将文件推送到远程repository
git push origin <localdir>:<remotedir> #将local dir文件推送到remote dir分支
git clone <ADDR> #克隆ADDR的文件到本地

git checkout <branchname> #跳转到branchname分支
git branch <branchname> #新建branchname分支
git branch -r #查看分支
git checkout -b <branchname> #跳转到新建的branchname分支

push到其他分支应该修改master就好了。我出现了这个错误:

$ git push origin master
To https://github.com/LiShanCheer/leaning.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/LiShanCheer/leaning.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

参考这个文件 解决了。这个是由于仓库中有文件,而且本地中没有;需要先整合才行。这样本地会包含远程repository中的全部文件。使用下面的命令:

git pull --rebase origin master
git push origin master #然后再使用push命令就可以了

参考文献

git GitHub基本操作
菜鸟教程-Git创建仓库
Git创建远程仓库并上传代码
Git常用命令

相关文章

  • GitHub--加入GitHub

    上一篇我们讲述了GitHub的基本概念,下面我们来讲述如何创建GitHub用户。推荐阅读:GitHub--初识Gi...

  • GitHub--初识GitHub

    说老实话,我目前还是个GitHub菜鸟,哈哈!还处于从GitHub上面Clone代码的阶段。当初,只是不断听别人说...

  • Github Visualization / Github 数据

    [TOC] Github Visualization / Github 数据可视化 网站链接: https://s...

  • GitHub之初识GitHub

    GitBub是什么,我就不阐述了,那么,我开始吧。 1 创建账户 首先,打开GitHub,出现如下所示: 右侧上角...

  • Github平台 加入Github

    那么多的不说,我继续更新。 为了更好的使用Github,第一步去了解这个平台是重要的。 因此这篇我将针对Githu...

  • 【GitHub】我的GitHub

    应大家要求,已将前期一些代码传至GitHub。用户名:ququcai,地址:https://github.com/...

  • 【GitHub】GitHub的使用

    基本指令 配置自己的身份:git config -- global user.name "Tony"设置自己的名字...

  • [ github ] github clone private

    当前前提: 1: 拥有github登陆账号2: mac电脑 本文所述: 1: 创建一个新的私有工程2: 配置ssh...

  • github - github注册(一)

    前言 github面向开源及私有软件项目的 托管 平台github是 分布式 的 版本控制 系统微软收购githu...

  • Github

    1.在命令行中,输入“git init”,使Test文件夹加入git管理;2.输入“git add .”(不要漏了...

网友评论

      本文标题:GitHub

      本文链接:https://www.haomeiwen.com/subject/knfsfktx.html