美文网首页
Git入门——远程仓库

Git入门——远程仓库

作者: fanison | 来源:发表于2019-11-17 11:19 被阅读0次

    1. 新建仓库


    Repository name:填写仓库名称

    2. 上传代码



      git remote add origin git@xxxxxxx   在本地添加远程仓库地址
      git push -u origin master           推送本地master到远程origin的master分支
    
    上传完毕

    3. 下载代码


    git clone git@?/xxx.git      下载代码
    git clone https://github.com/?/xxx.git
    注: 下载别人代码使用https地址
         下载自己代码https、ssh均可
    

    4. 上传到两个远程仓库

        第二个仓库上传时使用如下代码:
            git remote add origin2 git@xxx.git
            git push -u origin2 master
    
    效果图

    5. git高级操作

    使用bash alias简化命令
    touch ~/.bashrc
    echo 'alias ga="git add"'>> ~/.bashrc
    echo 'alias gc="git commit -v"'>> ~/.bashrc
    echo 'alias gl="git pull"'>> ~/.bashrc
    echo 'alias gp="git push"'>> ~/.bashrc
    echo 'alias gco="git checkout"'>> ~/.bashrc
    echo 'alias gst="git status -sb"'>> ~/.bashrc
    echo 'alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- | less"' >> ~/.bashrc
    

    ga、gc、gl、gp、gco、gst、glog

    git rebase -i XXX       美化历史命令
    git stash               临时隐藏代码
    git stash pop           显示临时隐藏代码
    

    相关文章

      网友评论

          本文标题:Git入门——远程仓库

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