• Git 基本操作


    Git

    Install

    sudo apt-get install git
    

    Connect

    1. Generate ssh key in local system
    ssh-keygen -t rsa -C "xxx@mail.com"
    
    1. Add ssh key to Github

    Copy content in /home/lzy/.ssh/id_rsa.pub or /root/.ssh/id_rsa.pub to Github New SSH key

    1. Configure
    git config --global user.name "linzhenyuyuchen"
    git config --global user.email "xxx@mail.com"
    
    1. Test
    ssh -T git@github.com
    

    Local Repo

    Make Repo

    cd /dir/repo/
    git init
    

    Add

    git add file.txt
    git add .
    

    Commit

    git commit -m "comment"
    

    Push

    Make sure # Remote Repo Done before push

    git push -u origin master
    

    Remote Repo

    Create Repo

    1. Login Github

    2. Create a repo with the same name

    3. Command under /dir/repo/

    更换源

    git remote rm origin
    
    git remote add origin git@github.com:linzhenyuyuchen/Pytorch-SSD-EAD2020.git
    

    git 分支管理

    # 列出分支
    git branch
    
    # 删除分支
    git branch -d branchname
    
    # 创建分支
    git branch branchname
    
    # 切换分支
    git checkout branchname
    

    合并分支到master

    git checkout master
    git pull origin master
    git merge branchname
    git status
    git push -u origin master
    
    

    Error

    hint: Updates were rejected because the remote contains work that you do

    # 如果可以接受强制覆盖
    git push -u origin master -f
    
    # 若不想合并远程和本地的内容,则创建分支
    git branch [name]
    git push -u origin [name]
    

    fatal: refusing to merge unrelated histories

    git pull origin master --allow-unrelated-histories
    

    总是出现要用户名和密码

    git remote set-url origin git+ssh://git@github.com/linzhenyuyuchen/repo_name.git
    
  • 相关阅读:
    服务端跳转和客户端跳转的区别
    jsp:include标签与include指令的区别
    jsp错误页不跳转显示500
    使用Cookie进行会话管理
    深入理解重定向和转发
    appium环境搭建(二)----搭建android开发环境
    appium环境搭建(一)----安装appium
    Fiddler实现移动端手机抓包
    黑盒测试人员必备技能
    SVN服务器搭建
  • 原文地址:https://www.cnblogs.com/linzhenyu/p/13372117.html
Copyright © 2020-2023  润新知