Git简单使用

1.初始化一个git项目:

git init

2.添加一个新文件,执行git status

PS D:\gittest> git status
On branch master

Initial commit

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

        test.py

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

提醒将新建文件git add
3. git add test.py,然后git status

PS D:\gittest> git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   test.py

快照已经生成,提醒提交
4.删除快照git rm –cached test.py,然后git status

PS D:\gittest> git status
On branch master

Initial commit

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

        test.py

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

5.回到步骤3的最终状态,修改test.py,然后git status

PS D:\gittest> git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   test.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   test.py

Changes not staged for commit说明文件已经修改,如果此时提交,提交内容为上次git add的文件,新修改内容没提交;可以通过git add再次更新快照,或者通过git checkout覆盖这次的修改。

  • 删除本地旧分支,拉取新分支
#!/bin/bash
set -e 

cd /project/
git pull
git fetch ori --prune
git branch -r|sed 's/ori\///g'|grep -v HEAD > $(dirname "$0")/version 
#显示所有分支,并去掉ori/前缀,过滤掉HEAD分支,并写到脚本同级目录下的version文件中
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值