首页 > 其他分享 >Git 使用以及常用命令

Git 使用以及常用命令

时间:2024-03-02 13:24:04浏览次数:24  
标签:demo git futantan 常用命令 192 Git 使用 txt hello

1. Git 常用命令

192:Desktop futantan$ git config --global user.name dandan_claire

192:Desktop futantan$ git config --global user.email [email protected]

192:Downloads futantan$ cd git-demo/

git add 文件名 (到暂存区)

192:git-demo futantan$ git init 
###初始化git
Initialized empty Git repository in /Users/futantan/Downloads/git-demo/.git/

192:git-demo futantan$ ls -a

. .. .git

192:git-demo futantan$ touch hello.txt
###在git 文件下创建一个文件试试看
192:git-demo futantan$ vim hello.txt 

192:git-demo futantan$ tail -n 2 hello.txt 

im fine too
192:git-demo futantan$ tail -n 1 hello.txt 
192:git-demo futantan$ git status 
On branch master
No commits yet
Untracked files:

  (use "git add <file>..." to include in what will be committed)
 hello.txt
nothing added to commit but untracked files present (use "git add" to track)
192:git-demo futantan$ git add hello.txt 
192:git-demo futantan$ git status 
On branch master
No commits yet
Changes to be committed:

  (use "git rm --cached <file>..." to unstage)
new file:   hello.txt
192:git-demo futantan$ git --version
git version 2.20.1 (Apple Git-117)
192:git-demo futantan$

时这个hello.txt 在暂存区了

下面的命令就是把文件从暂存区删除,但是文件还存在于工作区

192:git-demo futantan$ git rm --cached hello.txt 

rm 'hello.txt'

192:git-demo futantan$ git status 

On branch master

No commits yet

Untracked files:

  (use "git add <file>..." to include in what will be committed)

 hello.txt

nothing added to commit but untracked files present (use "git add" to track)

192:git-demo futantan$ ls

hello.txt

将暂存区的文件提交到本地库

基本语法,git commit -m "日志信息" 文件名

提交后用git log 或者git reflog

 修改文件(hello.txt)(以下红色的hello.txt 说明文件hello.txt还没有添加到暂存区)

 git add hello.txt

 git commit -m "xxxx" hello.txt

然后就可以查到两个版本了

 

标签:demo,git,futantan,常用命令,192,Git,使用,txt,hello
From: https://www.cnblogs.com/clairedandan/p/18048532

相关文章

  • 使用 Docker 部署 Nacos 并配置 MySQL 数据源
    前言在安装Nacos之前,请确保你已经准备好了一个运行中的MySQL数据库。本教程将指导您如何使用Docker在单机模式下部署Nacos,并将其数据持久化到MySQL中。步骤一:拉取Nacos镜像拉取最新版本的NacosServer镜像,也可以指定特定版本:dockerpullnacos/nacos-server如果你......
  • Go语言的100个错误使用场景(55-60)|并发基础
    目录前言8.并发基础8.1混淆并发与并行的概念(#55)8.2认为并发总是更快(#56)8.3分不清何时使用互斥锁或channel(#57)8.4不理解竞态问题(#58)8.5不了解工作负载类型对并发性能的影响(#59)8.6不懂得使用Gocontexts(#60)小结前言大家好,这里是白泽。《Go语言的100个错误以及如何避免》......
  • 使用developer API压缩
    key/***中转压缩url*/publicfinalstaticStringTINIFY_URL="https://api.tinify.com/shrink";/***tinifyapiKey*/publicfinalstaticStringAPI_KET="xxxxx"; controller@PostMapping("/u......
  • IFS分隔符的使用
     替换换行符IFS和echo一起配合才有作用#!/bin/bashecho$IFS|od-bold_if=$IFSIFS=$'\n'echo`lsmod|awk'{print$1}'`IFS=$old_ifecho$IFS|od-b结果00000000120000001Modulebinfmt_miscxt_LOGnf_log_syslogxt_setip6t_rpfilterip6table_natip......
  • 深入浅出Gitlab Runner自动构建C#应用程序
    概述程序员签入代码到Gitlab之后,GitlabRunner自动从流水线领取作业。按我们编排的“作业”,流水线工作步骤如下:程序员在Windows的VisualStudio2022中签入了“解决方案A”到Gitlab;Gitlab根据我们编排的.gitlab-ci.yml创建“流水线”;GitlabRunner领取到“作业”,以指定映像......
  • 笔记:Git学习之应用场景和使用经验
    目标:整理Git工具的应用场景和使用经验一、开发环境Git是代码版本控制工具;Github是代码托管平台。工具组合:VSCode+Git需要安装的软件:vscode、Git其中vscode需要安装的插件:GitLens、GitHistory二、应用场景工作场景:嵌入式开发,多人本地使用三、使用总结基础操作,参考廖雪峰的Git教......
  • Gitlab Runner自动执行Docker容器
    概述Gitlab完全可以执行dockerrun命令,本文用最简单的方式来演示。修改.gitlab-ci.yml加入第4个stage,运行dockerrun。stages:-build-docker-image-test-push-image-run-websitevariables:PAY_IMAGE_FULL_URL:docker.amihome.cn/amihome/chang......
  • Gitlab Runner自动推送Docker映像
    接上文,增加两个stage最简单的推送,其实是在dockerbuild后边带上--push的开关即可。但是不经过测试就上传,Docker仓库里很快会堆满垃圾。所以我们设计新增两个场景,经过测试之后才push映像去仓库。stages:-build-docker-image-test-push-imagevariables:......
  • Gitlab Runner自动制作C#网站项目的Docker映像
    概述代码签入Gitlab后,GitlabRunner自动执行dockerbuild,构建网站应用的Docker映像。在VisualStudio2022中创建解决方案在Gitlab中创建项目这一步省略。签入源代码到Gitlab为项目添加Dockerfile在解决方案根目录下创建“.gitlab-ci.yml”stages:-build-docke......
  • C++类开发的第六篇(虚拟继承实现原理和cl命令的使用的bug修复)
    Class_memory接上一篇末尾虚拟继承的简单介绍之后,这篇来详细讲一下这个内存大小是怎么分配的。使用clcl是MicrosoftVisualStudio中的C/C++编译器命令。通过在命令行中键入cl命令,可以调用VisualStudio的编译器进行编译操作。cl命令提供了各种选项和参数,用于指定源......