zoukankan      html  css  js  c++  java
  • GitHub使用简介

    1、创建新项目

    登陆到GitHub(https://github.com/)并注册后,选中New repository, 填写相关信息并点击Create repository即可。

    2、版本管理

    a) git clone https://github.com/$(USERNAME)/$(REPO).git

    b) vim README.md

    # This is my first GitHub program. freeos
    ======
    
    A small OS according to MIT OS lecture.
    
    ## Repo Address:
    
    * HTTP protocol: https://github.com/$(USERNAME)/$(REPO).git
    * GIT protocol: git://github.com/$(USERNAME)/$(REPO).git
    
    ## Clone repo
    
    You can get it by:
    https://github.com/$(USERNAME)/$(REPO).git

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    c) git add README.md

    d) git commit -m "$(YOUR MESSAGE)"

    e) vim .git/config

    [core]
        repositoryformatversion = 0 
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://$(USERNAME):$(PASSWD)@github.com/$(USERNAME)/$(REPO).git
    #   url = git://github.com/$(USERNAME)/$(REPO).git
    [branch "master"]
        remote = origin
        merge = refs/heads/master

    如上,将url = git://github.com/$(USERNAME)/$(REPO).git

    修改为:url = https://$(USERNAME):$(PASSWD)@github.com/$(USERNAME)/$(REPO).git

    f) git push origin master

    这样就可以看到在GitHub上的修改了。

    如果全部使用命令行创建:

    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/ym65536/$(PROG).git
    git push -u origin master

    常用命令:

    1、获取远程分支

    git fetch origin
    git checkout -b <local-branchname> origin/<remote_branchname>

     2、推送到远程分支

    git push origin <local-branch>:<remote_branch>

     3、查看和切换分支

    查看:git branch
    切换:git checkout <local_branch>

    questions:

    1、

    If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

    https://help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled

    You may also need to update the origin for your repository if set to https:

    1 git remote -v 
    2 git remote remove origin 
    3 git remote add origin git@github.com:user/repo.git  

    2、最近一段时间在使用 git log 和 git diff 命令的时候一直有乱码出现,具体表现为在行首出现 ESC[33,而在行尾出现 ESC[m

    git 使用的默认分页程序是 less,而默认的直接运行 less 的话,会无法正确解析转义字符。但是如果以 -r 命令来运行 less 的话,就可以解决了。故解决办法就是将 git 的默认分页程序改为 “less -r” 来运行,如下:

    git config --global core.pager "less -r"
  • 相关阅读:
    ecmall挂件开发实例二(转)
    ecmall 挂件开发实例一
    ecmall公告挂件分析(转)--此挂件写法已有更新的写法。
    centos下svn的主要常用命令(解决商城系统添加的文件无法自动更新至svn服务器)
    lbypmall虚拟主机的设置
    解决EditPlus的默认编码方式有关问题(转)
    php mysql 字符集(三) (转)
    php mysql apache字符集(二) (转)
    php mysql apache 的字符集
    Android学习笔记——文件路径(/mnt/sdcard/...)、Uri(content://media/external/...)学习
  • 原文地址:https://www.cnblogs.com/ym65536/p/4087717.html
Copyright © 2011-2022 走看看