If you've added files to the staging area (the Index) accidentally - you can remove them using git reset.

We'll first add a file to staging, but then back it out with:

git reset HEAD filename

in order to pull it back to the working directory, so it doesn't end up in a commit when we don't want it to.

You created a new file lib.js

You have add to stating area.

git status
git add .

But later you find out that you don't want to add lib.js

git log --oneline

Run:

git reset HEAD lib.js

It will untrack lib.js file.

[Git] Remove Files from Staging Before Committing的更多相关文章

  1. Github & DMCA Takedown & git remove history

    Github & DMCA Takedown & git remove history Github & DMCA Takedown Policy Removing files ...

  2. [Practical Git] Remove unnecessary git tracking with .gitignore files

    Most projects have automatically generated files or folders from the operating system, applications, ...

  3. Git CMD - rm: Remove files from the working tree and from the index

    命令格式 git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>…​ 命令参 ...

  4. GIT使用[git remove untracked working file]

    使用GIT进行merge的时候, git merge --no-ff master 如果merge之后出现问题, 想进行回退, 可以使用 git reset --hard HEAD 来回退到最新的版本 ...

  5. git remove cache

    若在提交.gitignore之前,不小心提交了无用的文件入repo,可以用以下命令在repo中去除这些文件 git rm -r --cached <filename or .> git a ...

  6. Git - Tutorial [Lars Vogel]

    From: http://www.vogella.com/tutorials/Git/article.html Git - Tutorial Lars Vogel Version 5.6 Copyri ...

  7. Git - Tutorial官方【转】

    转自:http://www.vogella.com/tutorials/Git/article.html#git_rename_branch Lars Vogel Version 5.8 Copyri ...

  8. How to get started with GIT and work with GIT Remote Repo

    https://www.ntu.edu.sg/home/ehchua/programming/howto/Git_HowTo.html#zz-7. 1.  Introduction GIT is a ...

  9. try git

    Git allows groups of people to work on the same documents (often code) at the same time, and without ...

随机推荐

  1. windows 安装 scrapy (python3.7)

    今天想要用scrapy爬取数据,想到原来刷过机没有这个库了就重新安装了一遍 安装scrapy 需要的东西   https://pan.baidu.com/s/1kuLvGQBG8tMTCY3WDLuU ...

  2. spring 事件使用

    1.事件定义 import lombok.Data; import org.springframework.context.ApplicationEvent; /** * 事件定义,这里监听MsgMe ...

  3. SQL中GROUP BY用法示例

    概述 GROUP BY我们可以先从字面上来理解,GROUP表示分组,BY后面写字段名,就表示根据哪个字段进行分组,如果有用Excel比较多的话,GROUP BY比较类似Excel里面的透视表. GRO ...

  4. Python协程介绍(转)

    原文:https://www.liaoxuefeng.com/wiki/897692888725344/923057403198272 协程,又称微线程,纤程.英文名Coroutine. 协程的概念很 ...

  5. Java学习:数据库连接池技术

    本节内容 数据库连接池 Spring JDBC : JDBC Template 数据库连接池 1.概念:其实就是一个容器(集合),存放数据库连接的容器 当系统初始化好后,容器中会申请一些连接对象,当用 ...

  6. Java面试宝典(2020版)

    一.Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境. JRE:Java ...

  7. java面试经常涉及到的

    需要掌握的Java知识点: 1 基本数据类型.循环控制.String类型的使用.数组.类和对象.接口和抽象类.面向对象三大特征.异常处理.集合类(List.Map.Set) 2 能够熟练使用Sprin ...

  8. 正则表达式回溯导致的CPU打满

    参考: https://my.oschina.net/ttscjr/blog/2208526 https://mp.weixin.qq.com/s?__biz=MzA4MjIyNTY0MQ==& ...

  9. 【转载】C#如何往DataTable中新增一个数据列

    在C#中的Datatable数据变量的操作过程中,有时候我们需要往现有的DataTable中新增一个自定义数据列,该列在原有的DataTable变量中并不存在,属于用户手工自定义新增的数据列,在往Da ...

  10. Vue Nginx反向代理配置 解决生产环境跨域

    Vue本地代理举例: module.exports = { publicPath: './', devServer: { proxy: { '/api': { target: 'https://mov ...