zoukankan      html  css  js  c++  java
  • git 常用命令语句(个人笔记)

    切换账户

    git config user.name xxxxx     查看用户名 
    ex: git config user.name tongjiaojiao
     
    git config user.email xxxxxx        查看用户邮箱
    ex: git config user.email 1881065****.163.com
     

    从线上拉新分支

    相当于新建一个分支,从线上切分支,是为了获取到线上最新最全的代码,不会出现不必要的冲突或bug

    git checkout -b xxxxxx origin/master

    ex: git checkout -b tjj/dev origin/master

    切换分支

    代码与当前分支保持一致

    git pull origin xxxxxx
    Ex: git pull origin tjj/saleList 
     

    查看本地所有分支

    git branch

    日志

    git reflog

    版本回退

    git log --pretty=oneline (出现的一堆数字是 commit id:版本号)

    回退至上一个版本:
     
    git reset --hard HEAD^
     
    回退至上100个版本
     
    git reset --hard HEAD~100
      4dfe5123012cd4596740b80a70303fb132079fb9
    或者是直接输入你的版本号(前几位就可以)
     
    git reset --hard 3628164 
     
    • HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。
    • 穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。
    • 要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。
     

    打tag

    git打tag 方便回退
    git tag  -a 1.2.1  
     

    修改分支名称

    git branch -m old_branch new_branch // 重置本地分支名称
     
    Ex:git branch -m tongjiao/new_index tongjiao/contract
     
    git push origin :old_branch 删除旧分支
     
    git push origin :tongjiao/new_index
     
    git push --set-upstream origin new_branch // 推送新分支,设置本地分支以跟踪新远程
     
    git push --set-upstream origin tongjiao/contract
     

    推送新分支,设置本地分支以跟踪新远程

  • 相关阅读:
    Java:多线程<一>
    Java:Exception
    Java: 内部类
    Ubuntu安装jdk
    ubuntu搜狗拼音安装
    录音-树莓派USB摄像头话筒
    leetcode 最小栈
    leetcode 编辑距离 动态规划
    leetcode 最小覆盖字串
    leetcode 最长上升子序列 动态规划
  • 原文地址:https://www.cnblogs.com/tongjiaojiao/p/11988993.html
Copyright © 2011-2022 走看看