git-add

Removing multiple files from a Git repo that have already been deleted from disk

醉酒当歌 提交于 2019-11-27 01:54:44
I have a Git repo that I have deleted four files from using rm ( not git rm ), and my Git status looks like this: # deleted: file1.txt # deleted: file2.txt # deleted: file3.txt # deleted: file4.txt How do I remove these files from Git without having to manually go through and add each file like this: git rm file1 file2 file3 file4 Ideally, I'm looking for something that works in the same way that git add . does, if that's possible. For Git 1.x $ git add -u This tells git to automatically stage tracked files -- including deleting the previously tracked files. For Git 2.0 To stage your whole

git add * (asterisk) vs git add . (period)

无人久伴 提交于 2019-11-26 21:22:18
I'm new to git and I have a question about adding files in git. I have found multiple stackoverflow questions about the difference between git add . and git add -a , git add --all , git add -A , etc. But I've been unable to find a place that explains what git add * does. I've even looked at the git add man page , but it didn't help. I've been using it in place of git add . and my co-worker asked me why. I didn't have an answer. I've just always used git add * . Are git add . and git add * the same? Does one add changed files from the current directory only, while the other adds files from the

git add --interactive “Your edited hunk does not apply”

浪子不回头ぞ 提交于 2019-11-26 18:33:11
I'm trying to use git add --interactive to selectively add some changes to my index, but I continually receive the "Your edited hunk does not apply. Edit again..." message. I get this message even if I choose the e option, and immediately save/close my editor. In other words, without editing the hunk at all, the patch doesn't apply. Here's the exact example I'm using (I'm trying to put together a small demo): Original file: first change second change off branch third change off branch second change third change fourth change New file: Change supporting feature 1 first change second change off

What's the difference between `git add .` and `git add -u`?

前提是你 提交于 2019-11-26 16:04:59
I was assuming that both work in the same way. Both add every file onto index. But I seem wrong. What's the difference between git add . and git add -u ? VonC It is one of the git gotchas mentioned here (pre Git 2.0). git add . only adds what is there, not what has been deleted (if tracked). git add . git commit git status //hey! why didn't it commit my deletes?, Oh yeah, silly me git add -u . git commit --amend git add -A would take care of both steps... With Git 2.0, git add -A is default . git add <path> is the same as " git add -A <path> " now, so that " git add dir/ " will notice paths

Recover files that were added to the index but then removed by a git reset

北慕城南 提交于 2019-11-26 15:27:56
I added some files to the index but then by mistake I deleted them with git reset --hard . How do I recover them? Here's what happened: I added all files using git add . I then committed When I checked the status, there were still files that weren't included in the commit from the add, which was strange I added the untracked files again and it worked this time But I wanted everything to be in 1 single commit so I looked up how to unstage what I just committed I used git reset --hard HEAD^ — bad idea obviously, all files were deleted so then I used git reflog to find where I left off then I

Add all files to a commit except a single file?

柔情痞子 提交于 2019-11-26 14:57:27
问题 I have a bunch of files in a changeset, but I want to specifically ignore a single modified file. Looks like this after git status : # modified: main/dontcheckmein.txt # deleted: main/plzcheckmein.c # deleted: main/plzcheckmein2.c ... Is there a way I can do git add but just ignore the one text file I don't want to touch? Something like: git add -u -except main/dontcheckmein.txt 回答1: git add -u git reset -- main/dontcheckmein.txt 回答2: 1) To start ignoring changes to a single already versioned

Removing multiple files from a Git repo that have already been deleted from disk

纵饮孤独 提交于 2019-11-26 09:49:13
问题 I have a Git repo that I have deleted four files from using rm ( not git rm ), and my Git status looks like this: # deleted: file1.txt # deleted: file2.txt # deleted: file3.txt # deleted: file4.txt How do I remove these files from Git without having to manually go through and add each file like this: git rm file1 file2 file3 file4 Ideally, I\'m looking for something that works in the same way that git add . does, if that\'s possible. 回答1: For Git 1.x $ git add -u This tells git to

git add * (asterisk) vs git add . (period)

孤街醉人 提交于 2019-11-26 06:58:00
问题 I\'m new to git and I have a question about adding files in git. I have found multiple stackoverflow questions about the difference between git add . and git add -a , git add --all , git add -A , etc. But I\'ve been unable to find a place that explains what git add * does. I\'ve even looked at the git add man page, but it didn\'t help. I\'ve been using it in place of git add . and my co-worker asked me why. I didn\'t have an answer. I\'ve just always used git add * . Are git add . and git add

git add --interactive “Your edited hunk does not apply”

给你一囗甜甜゛ 提交于 2019-11-26 06:27:34
问题 I\'m trying to use git add --interactive to selectively add some changes to my index, but I continually receive the \"Your edited hunk does not apply. Edit again...\" message. I get this message even if I choose the e option, and immediately save/close my editor. In other words, without editing the hunk at all, the patch doesn\'t apply. Here\'s the exact example I\'m using (I\'m trying to put together a small demo): Original file: first change second change off branch third change off branch

What&#39;s the difference between `git add .` and `git add -u`?

早过忘川 提交于 2019-11-26 04:40:58
问题 I was assuming that both work in the same way. Both add every file onto index. But I seem wrong. What\'s the difference between git add . and git add -u ? 回答1: It is one of the git gotchas mentioned here (pre Git 2.0). git add . only adds what is there, not what has been deleted (if tracked). git add . git commit git status //hey! why didn't it commit my deletes?, Oh yeah, silly me git add -u . git commit --amend git add -A would take care of both steps... With Git 2.0, git add -A is default.