git 常见场景使用及常用命令介绍

一 摘要

本文主要介绍git常用命令及配置。

二 环境信息

2.1 git版本

C:\Users>git --version
git version 2.24.0.windows.2

三 常见场景

3.1 某类文件不想push 到git 远程库

参考官方文档 https://git-scm.com/docs/gitignore
比如c&c++ 编译的exe 文件
在这里插入图片描述

3.1.1 修改配置

修改项目目录下 .git/info/exclude 文件
新增*.exe 即可

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
*.exe

3.1.1 验证

PS D:\jichu\data-structure-yanweimin> git add .
PS D:\jichu\data-structure-yanweimin> git status
On branch develop
Your branch is up to date with 'origin/develop'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   cpp/chapter0/0-1.cpp
        new file:   cpp/chapter0/0-2.cpp
        new file:   cpp/chapter0/0-3.cpp
        new file:   cpp/chapter1/1.4/1.4.cpp
        new file:   cpp/chapter2/2.13-.214/2.13-2.14.cpp
        new file:   cpp/chapter2/2.13-.214/book.txt
        new file:   cpp/chapter2/2.15linkedlist/2.15linkedlist.cpp
        new file:   cpp/chapter2/2.15linkedlist/listA.txt
        new file:   cpp/chapter2/2.15linkedlist/listB.txt
        new file:   cpp/chapter2/2.15sequencelist/2.15sequencelist.cpp
        new file:   cpp/chapter2/2.15sequencelist/listA.txt
        new file:   cpp/chapter2/2.15sequencelist/listB.txt
        new file:   cpp/chapter2/2.16/2.16.cpp
        new file:   cpp/chapter2/2.16/ListA.txt
        new file:   cpp/chapter2/2.16/ListB.txt
        new file:   cpp/chapter2/2.17/2.17.cpp
        new file:   cpp/chapter2/2.17/ListA.txt
        new file:   cpp/chapter2/2.17/ListB.txt
        new file:   cpp/chapter2/2.18-2.19/2.18-2.19.cpp
        new file:   cpp/chapter2/2.18-2.19/PolyA.txt
        new file:   cpp/chapter2/2.18-2.19/PolyB.txt
        new file:   cpp/chapter2/2.6-2.12/2.6-2.12.cpp
        new file:   cpp/chapter2/2.6-2.12/book.txt
        new file:   cpp/chapter3/3.1-3.4/3.1-3.4.cpp
        new file:   cpp/chapter3/3.1-3.4/SqStack.txt
        new file:   cpp/chapter3/3.10/3.10.cpp
        new file:   cpp/chapter3/3.10/3.10.h
        new file:   cpp/chapter3/3.11-3.15/3.11-3.15.cpp
        new file:   cpp/chapter3/3.11-3.15/QNode.txt
        new file:   cpp/chapter3/3.5-3.8/3.5-3.8.cpp
        new file:   cpp/chapter3/3.5-3.8/SqStack.txt
        new file:   cpp/chapter3/3.9/3.9.cpp

可见 exe 文件并未add.

push 到远程仓库 也不包含.exe 文件
在这里插入图片描述

四 常用命令

4.1 gitclone 所有分支

gitclone 默认只会克隆主分支,需要执行以下命令将所有分支克隆

for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值