zoukankan      html  css  js  c++  java
  • Git常用命令拾遗

    git三个区

    下图是git的提交流程,是入门或者说是理解git的重要图谱。

    我们可以看到这里有三个区:工作区、暂存区、提交区。截止到commit阶段,其实都只是在本地离线操作,真正同步到中心服务器,需要使用push命令。

    git基础命令

    生成SSH-key

    ssh-keygen -t rsa -C "youremail@example.com"

    配置邮箱和名称

    git config --global --add user.name "jackyfei"

    git config --global --add user.email "4189823@qq.com"

    删除配置 unset

    git config --global --unset user.name

    工作区初始化

    git init

    查看状态/指明灯

    git status

    进入暂存区

    git add 文件名或者点号

    进入提交区

    git commit -m "desciption"

    git log和版本切换

    查看日志

    git log //退出q

    回退

    git reset --hard commitid

    git reset --hard HEAD^

    简写,单行显示

    git log --pretty=oneline

    查询所有commitid

    git reflog 回退后,最新的commitid没了,如果又想再次返回可用git reflog查询所有commitid

    git分支

    从主分支上切出一个开发分支dev_jacky,使用到关键字-b

    git checkout -b dev_wang

    查看分支

    git branch

    切换分支

    git checkout master

    删除分支,必须在其他分支上操作

    git branch -d dev_wang

    强制删除分支

    git branch -D dev_wang

    删除线上分支并同步到本地

    git branch -a

    git remote prune origin

    git配置和别名

    查看config信息

    git config -l

    git config --global -l / -e

    git config --local -l / -e

    git config --system -l / -e

    配置用户名邮箱

    git config --global --add user.name "zhangsan"

    git config --global --add user.email "323232@qq.com"

    删除配置

    git config global --unset user.name

    配置别名

    git config --global alias.st status

    git config --global alias.cm commit

    打标签和忽略文件

    git tag 标签名 commitid

    git tag 标签名 -m "说明内容"

    git tag -d 标签名

    .gitignore

    github有个各主流语言的gitignore的集合,非常齐全,遗憾的是没有收集C#相关的内容,以下罗列的是C#语言相关的忽略内容,供你参考:

    !/DLLs/
    *.exe
    *.exp
    *.ilk
    *.lib
    *.ncb
    *.log
    *.pdb
    *.vcproj.*.user
    *.suo
    ._*
    [Dd]ebug
    [Rr]elease
    obj/
    [Bb]in
    !packages/build/
    Bak/
    packages/
    [Rr]elease/
    Key/
    !NuGet.exe
    *.vs

    本地仓和远程仓

    查看远程

    git remote

    创建新仓

    git init

    git add . 或 README.txt

    git commit -m "说明"

    建立关联

    git remote add origin git@github.com:ThreeMammals/Ocelot.git

    git push -u origin master

    推送到已存在仓

    git remote add origin git@github.com:ThreeMammals/Ocelot.git

    git push -u origin master

  • 相关阅读:
    hdu2328 Corporate Identity
    hdu1238 Substrings
    hdu4300 Clairewd’s message
    hdu3336 Count the string
    hdu2597 Simpsons’ Hidden Talents
    poj3080 Blue Jeans
    poj2752 Seek the Name, Seek the Fame
    poj2406 Power Strings
    hust1010 The Minimum Length
    hdu1358 Period
  • 原文地址:https://www.cnblogs.com/jackyfei/p/10212485.html
Copyright © 2011-2022 走看看