A
A
Alexey Kalenchukov2020-10-11 16:15:25
git
Alexey Kalenchukov, 2020-10-11 16:15:25

Why do stage?

Why do stage, then commit, if you can make a commit without it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2020-10-11
@Casufi

Can you tell me how you commit files if you don't tell git to commit them?
5f8307810b3c8290768442.png
https://git-scm.com/book/en/v2

S
Saboteur, 2020-10-11
@saboteur_kiev

There are files in the workspace - just lying in the directory
. There are files in the stage prepared for commit.
git commit: Commits exactly what is in the stage, not what is in the directory.
git commit -a: Automatically adds all tracked files to stage and commits. But for example, a freshly added file that has not yet been in the git will not be included in the commit.
for example

echo "hello" > a.txt
git commit -m "add a.txt"

nothing will be committed,
but like this - it will be committed
echo "hello" > a.txt
git add a.txt
git commit -m "add a.txt"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question