How to specify the files I want to add to the Stage area?

Asked

Viewed 61 times

4

For example, I’m working on an x branch.

I changed the following files 1,2,3,4. I checked the git status all right. So far so good!

If I rotate the git add . will add the 04 files.

How would you add only files 1, 2 and 3 leaving the 4 out?

3 answers

3

The . (point) in git add (in GIT versions 2.x) says you want to add in Stage all modifications that were made (all new files, all modified files and everything that was deleted).

Specify the files on git add

git add 1 2 3
  • Okay, I’ll take the test here. Thank you!

0

You can also use some development ide to facilitate these processes.

For example in visual studio code,below Voce selects the file you want to add in Stage by clicking on + :

inserir a descrição da imagem aqui

And below Voce puts your commit message:

inserir a descrição da imagem aqui

By clicking the correct arrow, you commit. and clicking - you remove the file you added in Stage.

If you click on the synchronism symbol, it is possible to pull and push, the commands are used in that order, so do not overlap changes made in the branch

inserir a descrição da imagem aqui

0

One possible solution is to use as parameter git add the result of a subshell that when listing the directory ignore certain files. Example git add $(ls -I 4). It is possible to ignore file lists by extension, git add $( ls -I "*.h" "*.c").

Browser other questions tagged

You are not signed in. Login or sign up in order to post.