Reputation: 21759
I use git add *
most of the times, because I just want to push all the files changed. But one folder, which I don't want to push, is also pushed when there're new files in it. Is it possible to disable it?
Upvotes: 0
Views: 59
Reputation: 77053
But one folder, which I don't want to push, is also pushed when there're new files in it.
Assuming you don't want to push the newer files only, but want to keep track of older files within that directory, add the foldername to .gitignore
.
echo path/to/folder >> .gitignore
If you want to remove all the files within that folder to be stopped from tracking, do an additional 2 steps
git rm -r --cached foldername
git commit -m "removed previously tracked files"
Upvotes: 2
Reputation: 5203
Note the existence of git add -u
, which only stages modified files, and git add -p
, which will ask you for each changement before staging (in modified files).
There is also -i
; check the full manual here
Alternatively, you can do git add .
, it won't add the ignored files (ignored through .gitignore).
Upvotes: 1
Reputation: 6886
Add the folder to .gitignore
as an entry: yourfoldertoignore/
From man gitignore
o If the pattern ends with a slash, it is removed for the purpose of
the following description, but it would only find a match with a
directory. In other words, foo/ will match a directory foo and
paths underneath it, but will not match a regular file or a
symbolic link foo (this is consistent with the way how pathspec
works in general in Git).
In case you want to push the folder once in a while you will have to use the --force
switch to add anything beneath that directory.
Also I strongly recommend you to not push stuff blindly, (not even git add file.ext
) but also use the -p
option in order to review what you are actually going to push (git add -p
).
Upvotes: 1