Reputation: 30431
Instead of selecting files manually when using git add
, is there a way to group these files and assign them a name so all I have to do would be something like git add <groupname>
. That would then add all files within that group? Does that feature exist?
Edit: Thanks for all your replies. I know about git add <folder>/*
, but what if not all files within that folder are needed? I'm asking so a group of files (let's say 17 files) can be one fork while another group can be from another fork. The thing which bothers me is these files are spread out in different folders so uploading the folder alone won't work. It has to be by file.
Upvotes: 4
Views: 375
Reputation: 301177
git stash
may satisfy your use case. Just add the files in the first group and stash them. Then add the files in the next group and stash them. Now you can pop the stashes as per your needs and commit them.
Upvotes: 1
Reputation: 4703
You might consider using a git alias. For example, you can add this to the .git/config
file in your repository (or in your ~/.gitconfig
):
[alias]
add-foo = add foo1 foo2 foo3
add-bar = add bar1 bar2 bar3
Then you can run git add-foo
to add the files foo1
, foo2
, and foo3
.
man git-config
for more details on git aliases.
Of course, you could always use shell aliases too.
Upvotes: 1
Reputation: 1144
You can add folders as a group, by basically doing git add [foldername]*
but no, git doesn't include a functionality to name a group of files. Can you explain exactly why and what the use case going forward would be? Would you want that name to persist between commits? Would you want the name to be stored in the repo and pulled down if someone cloned your repo?
Upvotes: 1