How to determine which commit deleted a specific line in git?

git blame deleted line
git log
git blame --reverse
find which commit deleted a file
git blame deleted file
git bisect
git find removed code
git blame start at line

Currently, based on this question I was able to come up with the following command:

git log -u -L 1626,1626:airflow/www/app.py 7399d6176181190a63b70eeec0f7012156c15332..HEAD

E.g. I'm looking for when line 1626 was modified (deleted) from airflow/www/app.py. The line number is valid in commit 7399d6, but not in HEAD, resulting in the following error:

fatal: file airflow/www/app.py has only 255 lines

(The file is much shorter since then.)

I think I wouldn't have this problem if the file was long enough. Can I maybe turn off this check somehow?

git blame path/to/file for each commit in your git log should do the trick.

Lots of modern IDEs also have an 'annotate' option if you right click to the left of the line number which will do the same thing graphically.

What does git blame do?

How to determine which commit deleted a specific line in git?, git blame path/to/file for each commit in your git log should do the trick. Lots of modern IDEs also have an 'annotate' option if you right click to� Stack Overflow Public questions and answers; Teams Private questions and answers for your team; Enterprise Private self-hosted questions and answers for your enterprise; Talent Hire technical talent

git blame --reverse might help you track down where this happened. You could try using a script that I developed for this task called difflame:

https://github.com/eantoranz/difflame

Git: How do I find which commit deleted a line?, I know I added a line in a particular commit and can see it in a private GitHub account. In my current branch it isn't in there any more. How do I find which commit� $ git log -- file2 Finding the commit that deleted a line. Finding the commit that deleted a line is slightly more complicated. Unfortunately, we can't really use git blame for that. All we can do with git blame is to find the last commit which contained the deleted line. So if we add the following file: $ cat file3 one two three $ git add

try this no commit ID

git log -L <fromLine,toLine>:<file>

Querying deleted content in git, Finding the commit that deleted a line is slightly more complicated. Unfortunately, we can't really use git blame for that. All we can do with git� Cool Tip: Revert a file to the previous commit! Read more → Git – Revert to Specific Commit. Find the specific commit you want to revert all changes to: $ git log --oneline. Rollback all changes to that old commit: $ git checkout be9055b . Note: The dot (.) after the branch name is mandatory. Add the changes to the staging area and commit them:

How to Git Blame a Deleted Line, If you know the content of the line, use the git log command: It doesn't point to the revision where the line is deleted but leads to the last The git log command is a Git tool which is used to examine a repository's history and find a particular� Now if you check the repository status, you will be able to see that Git staged a deletion commit. $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Changes to be committed: (use "git restore --staged <file>" to unstage) deleted: newfile. Now that your file is staged, simply use the “git commit” with the “–amend” option in order to amend the most recent commit from your repository.

Viewing the Commit History, As you can see, this command lists each commit with its SHA-1 checksum, the files were changed, and how many lines in those files were added and removed. The --author option allows you to filter on a specific author, and the --grep� In the first article in this series on getting started with Git, we created a simple Git repo and added a file to it by connecting it with our computer. In this article, we will learn a handful of other things about Git, namely how to clone (download), modify, add, and delete files in a Git repo.

How can I restore a deleted file in Git?, If you deleted a file, committed, then continued work and did more commits, only to find that deleting the file was a mistake, Git still has you covered! To find the� So, in order for the commits to get deleted upstream just like you did locally, push the branch with the "--force" argument. Otherwise pull it again from upstream to get your recently deleted commits back.

Comments
  • git rev-list 7399d6176181190a63b70eeec0f7012156c15332..HEAD | xargs -i sh -c 'git diff -r {}^..{} airflow/www/app.py | grep expose_config && echo {}' worked for me, where expose_config is part of the line I'm looking for. Not sure yet how to grep for any random string with taking care of escaping everything properly.
  • You might try combining git bisect with git grep as a faster way to find out when the line vanished: git bisect bad a commit that doesn't have the line, git bisect good a commit that does, and then use a script to check for the existence of the line as your bisect script (git bisect run).
  • git rev-list 7399d6176181190a63b70eeec0f7012156c15332..HEAD | xargs -i git blame airflow/www/app.py -L 1626,1626 {} 2>/dev/null | uniq Seems to work, but extremely slowly since there are 6490 commits between 7399d6 and HEAD. And it doesn't notice that the line number of the commit has increased, but the line itself is still there. I guess I'm looking for something a little bit more clever.