• Git 常用命令


    $git init

    $git add ss.txt

    $git commit -m "note"

    $git status

    $git diff xx.txt

    $git log --pretty=oneline 

    $git reset --hard HEAD^

    $git reflog

    $git chekout --xx.txt   //把工作区修改的xx.txt全部撤销

    $git reset HEAD name.txt //把stage中的name.txt文件撤销

    $git rm name.txt  //删除文件并提交

    $git remote add origin git@github.com:xx/xx.git

    $git push (-u) origin master //将本地分支推送到远程库

    $git clone git@github.com:xx/xx.git

    $git checkout -b dev  //创建dev分支并切换到dev

    $git branch 

    $git checkout master //切换master

    $git merge dev

    $git branch -d dev  //删除dev分支

    $git log --graph --pretty=oneline --abbrev-commit  //查看分支合并图

    $git merge --no-ff -m "merge with no-ff" dev  //禁用fast-forward的分支合并

    $git stash  //将当前工作现场存储起来

    $git stash list   //查看被保存的工作现场

    $git stash appy  //恢复工作现场  

    $git statch drop //删除工作现场

    $git branch -D dev //强行删除dev

    $git remote

    $git  rebase 

                                         dev1

    c1 <- c2 <- c3 <- c4 -< c5             git rebase dev1

                  <- c6 <- c7 -< c8            ------------------->          c1 <- c2 <- c3 <- c4 <- c5 <- c6 <- c7 <- c8

                                          dev2

    $git rebase --continue  //继续rebase

    $git rebase --abort      //停止rebase,回到rebase前的状态

    $git cherry-pick

                                         dev1          git checkout dev1

    c1 <- c2 <- c3 <- c4 -< c5            git chery-pick c6                                                          dev1

                  <- c6 <- c7 -< c8            ------------------->          c1 <- c2 <- c3 <- c4 <- c5 <- c6 

                                          dev2

    合并最近2个提交

    git rebase --interactive HEAD~2

    修改最后两个pick为fixup(丢失commit信息),wq保存

    git push -f

    修改最后一次的commit

    git rebase --interactive HEAD~1

    git commit --amend   

    修改commit信息,wq保存

    git rebase --continue

    git push -f

  • 相关阅读:
    对var和let作用域用闭包的特性做最好的解释
    Js函数作用域
    问题记录
    Git学习
    React-router BrowserRouter导致axios请求时会重复url中的某些字段
    leetcode python 032 识别最长合法括号
    leetcode python 030 Substring with Concatenation of All Words
    n阶楼梯,一次走1,2,3步,求多少种不同走法
    leetcode python 012 hard 合并k个有序链表
    leetcode python 011
  • 原文地址:https://www.cnblogs.com/forerver-elf/p/5481466.html
Copyright © 2020-2023  润新知