AMY
AMY

Reputation: 248

Remove deleted files from a commit in git repo

I have a commit in gerrit with three files in which there are two deleted files, But i don't want to merge those deleted changes. I have tried all sort of things with resetting those files, but as i am just checking out the change from gerrit, It doesn't seems to actually do anything.

This i have found on lot of places:

git add -u
git reset HEAD path/to/file
git commit

but didn't work. Does anyone know a way to accomplish this.

Upvotes: 1

Views: 2302

Answers (2)

stdcall
stdcall

Reputation: 28920

What you need to do. is cherry-pick the change-set from gerrit. And than in interactive fashion merge only the file you want. More details: partly cherry-picking a commit with git

Upvotes: 0

mirk
mirk

Reputation: 432

To delete the files via git.

 git rm path/to/filename

I did this test. Clone an existing git repo to deleteme. Removed the README file from the repo and commit the changes.

 $git clone /path/tomy/gitrepo deleteme
 $cd deleteme
 $rm README
 $git commit -a


 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit.
 # On branch master
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #       deleted:    README
 #

~
~
~
~

Upvotes: 1

Related Questions