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. 自学Dos的随堂笔记

    开启DOS控制台的几种方式 开始+windows系统+命令提示符. Win键+R,输入cmd打开控制台. 在任意文件夹下,按住shift键+鼠标右键点击,在此处打开命令窗口. 资源管理器的地址栏前面加 ...

  2. .net(2)

    11.interface是否可继承interface?abstract class 是否可实现interface 回答1:接口可以继承接口,而且可以继承多个接口,用“,”进行分割,接口不允许直接或间接 ...

  3. kubeadm安装依赖镜像

    使用kubeadm安装的时候如果不能翻墙下载镜像是个很大的问题,这里自己把需要的镜像下载push下留作不时之需 docker pull davygeek/kube-proxy:v1.14.2 dock ...

  4. 【题解】有限制的排列 [51nod1296]

    [题解]有限制的排列 [51nod1296] 传送门:有限制的排列 \([51nod1296]\) [题目描述] 给出 \(n,m_1,m_2\) 和 \(\{a[1],a[2]...a[m_1]\} ...

  5. datax分析与思考(一)

    Datax 总体流程图 先看执行的第一个步骤: 在最上层抽象类,这个里面相当于获取全局公共信息,java入口部分就是这个Engine的main方法直接启动 Engine 启动 com.alibaba. ...

  6. 你可能还不知道的关于JavaScript类型的细节?

    类型 七种类型: Undefined Null Boolean String Number Symbol Object Undefined.Null 阅读问题:为什么有的编程规范要求使用void 0 ...

  7. Android常用五种布局

    1. FrameLayout(框架布局) 这个布局可以看成是墙脚堆东西,有一个四方的矩形的左上角墙脚,我们放了第一个东西,要再放一个,那就在放在原来放的位置的上面,这样依次的放,会盖住原来的东西.这个 ...

  8. Spring Boot加载application.properties配置文件顺序规则

    SpringApplication会从以下路径加载所有的application.properties文件: 1.file:./config/(当前目录下的config文件夹) 2.file:./(当前 ...

  9. ES6 对象解构赋值(浅拷贝 VS 深拷贝)

    对象的扩展运算符(...)用于取出参数对象的所有可遍历属性,拷贝到当前对象之中. 拷贝对象 let aa = { age: 18, name: 'aaa' } let bb = {...aa}; co ...

  10. iview引用自定义的图标

    在vue脚手架中,目前项目使用的iview里面的图标,不够满足,需要自定义加入图标. 在阿里图标库:https://www.iconfont.cn 然后把本项目需要的图标可以放在里面. 然后将icon ...