0

when I modify or add files in local working directory, I can following these 3 steps to update the remote repo

git add .
git commit -m "message"
git push

if I delete file(s) in local working directory, for the first step I need to use git rm file_name instead of git add

then how about if I not only add some files but also delete some other files at the same time? what steps should I follow?

6
  • It works the same way. A single commit can include additions, deletions, and modifications. So what exactly is your question?
    – elixenide
    Commented Oct 18, 2015 at 19:22
  • @EdCottrell if I delete a file and use git add ., then the remote repo won't change. what single commit can include addition/deletion and modification?
    – lily
    Commented Oct 18, 2015 at 19:27
  • Well, don't use git add . to add a single file; that adds the entire current working directory (that's what the . means, after all). That would cancel out your git rm file_name. Use git add yourFileName. And keep in mind that add, rm, etc. never change the remote repository. Only committing and pushing your changes will change the remote repository.
    – elixenide
    Commented Oct 18, 2015 at 19:29
  • @EdCottrell I know commit and push are needed to update the remote repo. What I mean is for the first step, "if I add some files and also delete some files, also I modify some files", what command should I use? git add is for adding files, git rm is for removing files.
    – lily
    Commented Oct 18, 2015 at 19:32
  • 1
    I already explained that. Add the files you want to add, delete the ones you want to delete, and modify the ones you want to modify. Just don't add or delete the entire directory if that's not what you want to do.
    – elixenide
    Commented Oct 18, 2015 at 19:33

1 Answer 1

1

To add all modifications, added files and deleted files to the tracked files to be committed use git add -A then you can use git commit as you always do.

2
  • is --all equal to -A?
    – lily
    Commented Oct 18, 2015 at 19:41
  • Yes, it is the same. You can always run git help add and see the full official help.
    – nbermudezs
    Commented Oct 18, 2015 at 19:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.