-
Notifications
You must be signed in to change notification settings - Fork 1
Operations on files
Let's see what else we can do inside our lonely little branch.
- git add can be used on the files in a directory:
ben@GregoryHouse:~/tmp/testRepo (master)$ mkdir subdir
ben@GregoryHouse:~/tmp/testRepo (master)$ git add subdir
ben@GregoryHouse:~/tmp/testRepo (master)$ git status
# On branch master
nothing to commit (working directory clean)
ben@GregoryHouse:~/tmp/testRepo (master)$ vi subdir/someFile
ben@GregoryHouse:~/tmp/testRepo (master)$ git add subdir
ben@GregoryHouse:~/tmp/testRepo (master +)$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: subdir/someFile
#-
What happens when I add an empty directory?... Nothing. Remember git only tracks files, and their path. You can't track a directory. empty or not.
-
However if it is not empty you can add all files recursively in a directory. (be careful as you would add any file, even the ones you would like to avoid keeping).
-
Other commands deal with file management:
git mv, that renames or moves a file,git rm, that removes a file from the repository, while keeping its history. You may have a play with them. -
You can also revert the changes you have staged but not committed yet and git status is once again very helpful at giving us the right command for that: (use "git reset HEAD ..." to unstage) could we read in the previous call to git status. Let's try:
ben@GregoryHouse:~/tmp/testRepo (master +)$ git reset HEAD subdir/someFile
ben@GregoryHouse:~/tmp/testRepo (master)$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# subdir/Jump to Branching