git-rm

Difference between `git rm --cached` and `git update-index --assume-unchanged`?

陌路散爱 提交于 2019-12-05 02:21:38
I do not understand the difference between git rm --cached and git update-index --assume-unchanged . I'm aware that git rm --cached <file> will remove a file from the staging area. And, I know that git update-index --assume-unchanged <file> also does this. I've also seen both commands offered as suggestions to similar questions here on SO. Is there another affect of either of these two commands that makes them different? The command git rm --cached <file> is used to untrack files in a Git branch. This command will remove the file from the staging area and also will remove the file from the

How to undo a “ git rm -r -f * ”

故事扮演 提交于 2019-12-04 10:46:53
I was using git for the first time, I had a directory with several programs written in it and did the following steps I did git add . then git commit , then it i got a message Aborting commit due to empty commit message. Then i thought, let me commit group of files under common message. So i thought of removing all the added files. So i did git rm -r -f When i do a ls i have lost all my code. Is there any way that i can get them back, to my foolishness i don't have backup copy even. Things that i have followed till now I googled out some found some of the command but they are not working git

Git - Remove All of a Certain Type of File from the Repository

╄→尐↘猪︶ㄣ 提交于 2019-12-04 02:19:17
How do I remove all of a certain type of file from the Repository? I'm using git filter-branch --index-filter 'git rm -rf --cached **/*.jar' Either git is not expanding globs, or it isn't expanding ** in the way I'm expecting. You simply have to run this in order to remove all your jars from the index: git rm -r --cached **/*.jar Run this command from your root directory of the project and it will clean up and will remove all your file only from the staging area. git filter-branch --index-filter 'git rm -rf --cached **/*.jar' should work, but it's a bit silly because git globs ( * ) match path

Restore deleted file not staged in git

萝らか妹 提交于 2019-12-04 00:23:18
问题 I accidentally removed the entire directory of my source code...with a nice rm -r. I know, really bad; but fortunately, I had a git repo in the containing directory. Thus, git has a huge list of unstaged changes of deleted files. For example: "deleted: src/caronmonitor/server.py" How do I get these files back? There is advice all over the web to do: git checkout file or git revert <commit> But as I understand that will restore the file to it's state at the last commit. I don't want to go back

Git + Rails: How to restore files deleted with “git rm -r”?

风格不统一 提交于 2019-12-03 12:03:23
问题 I deleted my db folder in a rails application in with git rm -r I've tried git reset HEAD and git reset --hard HEAD but the migration files arent coming back. I tried commiting, then running the reset and still nothing. What should I do? 回答1: You can checkout the file from the commit where it still exists. Here's how to do it. git checkout <commit where the file still exists> -- db # Example: git checkout 6936142 -- db # This also works, but if you have a branch named the same as the file or

Git: need to recursively 'git rm' the contents of all bin and obj folders

浪子不回头ぞ 提交于 2019-12-03 11:42:37
问题 Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this? 回答1: Have backups, find . -type d -name bin -exec git rm -r {} \; find . -type d -name obj -exec git rm -r {} \; Update With bash, you can set the shopt globstar, and be happy: shopt -s globstar git rm -r **/{obj,bin}/ Finally, if you need to remove these from the history of the repository,

Git + Rails: How to restore files deleted with “git rm -r”?

我只是一个虾纸丫 提交于 2019-12-03 02:25:54
I deleted my db folder in a rails application in with git rm -r I've tried git reset HEAD and git reset --hard HEAD but the migration files arent coming back. I tried commiting, then running the reset and still nothing. What should I do? You can checkout the file from the commit where it still exists. Here's how to do it. git checkout <commit where the file still exists> -- db # Example: git checkout 6936142 -- db # This also works, but if you have a branch named the same as the file or path, # it will throw an error. git checkout 6936142 db You can checkout individual files from your last

Git: Undo local changes; git add . + git rm?

与世无争的帅哥 提交于 2019-12-03 02:24:37
Need help figuring out a couple common workflows with Github. I come from a VS TFS background, so forgive me. Undoing Pending Changes Let's say I have cloned of a git repository to my local file system. At this point, the project's local files match exactly what's in the remote repoistory. Then I decided to make some changes to the code, and change the local versions of a couple files. After doing some testing, I figure out that I want to discard my local changes and revert the local files back to what they are in the remote repoistory. How do I undo these local changes, restoring them to the

Git: need to recursively 'git rm' the contents of all bin and obj folders

自作多情 提交于 2019-12-03 02:08:46
Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this? Have backups, find . -type d -name bin -exec git rm -r {} \; find . -type d -name obj -exec git rm -r {} \; Update With bash, you can set the shopt globstar, and be happy: shopt -s globstar git rm -r **/{obj,bin}/ Finally, if you need to remove these from the history of the repository, look at git filter-branch and read the section on 'Removing Objects' from the Pro Git Book Once you revert

Restore deleted file not staged in git

廉价感情. 提交于 2019-12-01 03:21:00
I accidentally removed the entire directory of my source code...with a nice rm -r. I know, really bad; but fortunately, I had a git repo in the containing directory. Thus, git has a huge list of unstaged changes of deleted files. For example: "deleted: src/caronmonitor/server.py" How do I get these files back? There is advice all over the web to do: git checkout file or git revert <commit> But as I understand that will restore the file to it's state at the last commit. I don't want to go back to the last commit but instead go back to right before the delete operation. I can look in the gitk