10
Whenever I make several changes to files in Git, I go out by adding the changes one-by-one through the git add
. It’s a bit of a boring process, I wonder if you have a command to add all the "not staged" changes at once.
10
Whenever I make several changes to files in Git, I go out by adding the changes one-by-one through the git add
. It’s a bit of a boring process, I wonder if you have a command to add all the "not staged" changes at once.
10
9
You can add multiple files to git
through the interactive prompt git add -i
At the interactive prompt you have two options that are most commonly used that are:
update
(2
or u
): for you to choose which files have already been added previously, you want to add in Stage.add untracked
(4
or a
) for you to add files not yet included to git versioning.Selecting one of the above options, the interactive mode will open for you more or less like this:
staged unstaged path
1: unchanged +1/-1 folder/arquivo1.txt
2: unchanged +1/-1 folder/arquivo2.txt
3: unchanged +1/-1 folder/arquivo3.txt
4: unchanged +1/-1 folder/arquivo4.txt
5: unchanged +1/-1 folder/arquivo5.txt
6: unchanged +1/-1 folder/arquivo6.txt
7: unchanged +1/-1 folder/arquivo7.txt
You have several ways to add those files that are listed above in Stage.
2-4
adds files 2, 3, 4 and 5 at a time)*
-
before the number or range.You can run several commands at the same prompt too, examples:
# Adiciona ao stage todos arquivos, menos os numeros 4, 5 e 6
Update>> * -4-6
# Adiciona ao stage todos arquivos menos o 5
Update>> 1-3 4 6-7
The command git add - A
works but it is not recommended because it adds forcibly, all files that have not been versioned, this isn’t always good because sometimes you want to do commits separately to better contextualize your progress and also you may end up adding some unwanted file that wasn’t in the .gitignore
before.
Only two more commands to add changes that are very useful and are more frequently used.
git add -u
: adds all modified files to Stage, only files that have already been added to git will be added.
git add -p
: Adds chunks of code that have been modified, also works only with files already added to git and is most recommended to use, as you can better contextualize what you’re updating.
I hope it helped.
good answer, never tried to use git interactively ...
7
You can use:
git add -A
5
Using:
git add -A
and
git add --all
you get the same result (actually the first and an abbreviation of the second).
Another way would be to use er:
git add *
But for this to work you need to be in the root repository causing all files to be picked up by er.
In an extreme case if you want to make these commands even more abbreviated, you can try git aliases to abbreviate them.
4
If they are files NEW, there’s no escape from git add -A
or git add .
, however, if there are changes in files EXISTING:
git commit -am "Sua Mensagem"
Already add and send a message to your branch
Browser other questions tagged git
You are not signed in. Login or sign up in order to post.
Have you ever thought that there is a reason why you have to add all files manually?
– pmargreff