zoukankan      html  css  js  c++  java
  • 真正入坑git

    之前使用git一直用sourceTree可视化操作,直到今天刚好装不了sourceTree,所有只能苦逼的用git命令行了,真的一片空白,要做下笔记才行。

    创建sshKey

    创建ssh:
    ssh-keygen -t rsa -C "xxxxxx@qq.com"
    查看ssh
    cat ~/.ssh/id_rsa.pub
    

    git拉取指定分支

    git clone -b develop XXX 
    

      

    Permissions 0644 for ‘/root/.ssh/id_rsa’ are too open处理

    输入命令

    chmod 0600 /root/.ssh/id_rsa

    然后就可以密钥登陆了

    sftp  -oPort=50022  x@IP
    

      

    在电脑上创建一个文件夹,先Clone一份自己工程的项目分支(xxx屏蔽公司信息)

    git clone git@xxxx.gitlab.com:xxxxxx/SELand_Vertu
    

    进入项目的二级目录进入git客户端,确认要pull分支

    git branch看看当前的分支
    
    git checkout -b develop  切换到develop分支,因为我要pull拉去develop分支上的项目
    

    然后在将自己的项目分支同步项目主分支(我们项目分支为develop分支)

    git pull git@xxx.gitlab.com:xxx/SELand_Vertu develop

    每次提交代码时候,需要先同步项目主分支代码

    git status是哪些文件有所修改
    
    git diff 可以查询所修改的代码
    
    git add -A 增加自己所做的修改
    
    git commit -a 提交所有修改的代码
    
    git push origin develop 提交代码  

    常用流程

    git status 查看修改过的文件
    
    git add . 选择文件
    
    git commit -m "提交的信息" 备注
    
    git pull origin master 同步线上代码到本地
    
    git push origin master 本地代码推送到线上
    
    git reset --hard HEAD~1   回滚上一个版本
    

    git拉取指定分支

    git clone -b (远程分支) (远程库路径)
    

      

    详解:https://www.cnblogs.com/mengdd/p/4153773.html

    阿里云code:http://blog.csdn.net/dark00800/article/details/54571859

    解决github上传ssh-key后仍须输入密码的问题:http://blog.csdn.net/baidu_35085676/article/details/53456884

    git教程:https://www.yiibai.com/git/git_reset.html

    https://www.cnblogs.com/Jack-cx/p/9412940.html

    问题解决汇总

    is unmerged

    git reset first_Name.txt
    git checkout first_Name.txt

    先清对应文件,再git pull

    或者清除所有本地变更

    git reset HEAD

    也可以根据对应分支下拉代码

    git reset --hard origin/test

  • 相关阅读:
    LeetCode 32. 最长有效括号(Longest Valid Parentheses)
    LeetCode 141. 环形链表(Linked List Cycle)
    LeetCode 160. 相交链表(Intersection of Two Linked Lists)
    LeetCode 112. 路径总和(Path Sum)
    LeetCode 124. 二叉树中的最大路径和(Binary Tree Maximum Path Sum)
    LightGBM新特性总结
    sql service 事务与锁
    C#泛型实例详解
    C# 中的委托和事件(详解)
    C# DateTime日期格式化
  • 原文地址:https://www.cnblogs.com/cxscode/p/7805909.html
Copyright © 2011-2022 走看看