4
mohamed@mohamed:~/Projects/skyrocket$ git status 
On branch dev/SMMWEB-36
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:   config/puppet/modules/apt (new commits)
    modified:   config/puppet/modules/augeas (new commits)
    modified:   config/puppet/modules/concat (new commits)
    modified:   config/puppet/modules/elasticsearch (new commits)
    modified:   config/puppet/modules/file_concat (new commits)
    modified:   config/puppet/modules/git (new commits)
    modified:   config/puppet/modules/php (new commits)
    modified:   config/puppet/modules/postgresql (new commits)
    modified:   config/puppet/modules/redis (new commits)
    modified:   config/puppet/modules/stdlib (new commits)
    modified:   config/puppet/modules/vcsrepo (new commits)

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

    .idea/copyright/
    config/puppet/modules/blackfire/
    config/puppet/modules/inifile/
    dump.rdb
    keys.dev.pub
    keys.tags.pub

no changes added to commit (use "git add" and/or "git commit -a")

I do not know what (new commits) does mean? I do not want to commit these files. I tried to do

$ git checkout -- . 

What if i put config/puppet/* to gitignore file then updated the cache as following

$ git rm --cached -r . 

will this delete these files from repo. after pushing or merging with other branches?

LF00
  • 27,015
  • 29
  • 156
  • 295
Dahab
  • 518
  • 1
  • 5
  • 23

6 Answers6

0

git reset is the command to unstage file from git.

After unstaging the file, you can confirm it by git status command as well.

Santhosh J
  • 368
  • 3
  • 14
0

If the directories under config/puppet/modules/ are submodules, try

$ git submodule update

which worked for me. See https://stackoverflow.com/a/14422494/5794048

Murphy
  • 3,827
  • 4
  • 21
  • 35
0

If you want to save the modification for later use, just stash them with

git add . && git stash save "info for the modification".

If you want to drop the modification, just do

git add . && git reset --hard HEAD


Attach: to show what you have stashed with git stash list, to apply the stash with git stash pop

LF00
  • 27,015
  • 29
  • 156
  • 295
-1

Use git reset to unstage files !

Hyukchan Kwon
  • 382
  • 1
  • 5
  • 20
-1

With "git reset" you can undo all adds or with git reset file_name you can undo picked add

Orsox
  • 54
  • 3
-1

We can run command git reset --hard

Jlearner
  • 573
  • 4
  • 6
  • 3
    There should be no space between `--` and `hard`, as in [`--hard`](https://git-scm.com/docs/git-reset#Documentation/git-reset.txt---hard). Otherwise it gets treated as [`git reset -- `](https://git-scm.com/docs/git-reset#Documentation/git-reset.txt-emgitresetem-qlttree-ishgt--ltpathsgt82308203). – Gino Mempin Sep 18 '19 at 23:30