How do I upload all the files in the directory except for a specific one?

Asked

Viewed 664 times

2

I would like to upload all files from the directory, except the config.php. I basically use the command git add . to add all the files, but when you have few edited files, I do so:

git add arquivo1.php
git add arquivo2.php
git add arquivo3.php

The archive config.php in my machine is one way, but in the server has other specific variables. I don’t always need to send the config.php. I would like a command to upload all files except this one. I know there is a .gitignore and also this question about Ignore all files except one specific in GIT, but sometimes I need to send the file config.php, without ignoring it, when there is some specific configuration.

In "pseudo-command" it would be something like:

git add . exceto config.php

How to send all directory files except one specific?

  • And why not make use of the .gitignore to facilitate the process?

  • @Guilhermenascimento because it is not always necessary to ignore it. If it were fixed, would have already put there. It would be something even like the pseudo command, "Add it all and ignore this"... git add tudo exceto config.php

  • I understand, but the .gitignore does not need to be forever, you can edit it at any time on your local machine, ie it is a file adjustable to your need for any time.

  • Ah, got it, you don’t want to ignore the file, you want to ignore the modifications, that’s it?

3 answers

2


Ignore changes/modifications in GIT

If you want to ignore modifications to a specific "git server" file, what you can try is to force the assumption that there have been no changes (I think it is only necessary once):

git update-index --assume-unchanged foo/bar/baz/config.php

So the file that already exists in the repository will not be removed, but will no longer be updated, but if you make any changes that you need to update the config.php then use:

git update-index --no-assume-unchanged foo/bar/baz/config.php

And then in the next update use again --assume-unchanged in the config.php

Ignore upload (remove the file)

If you want to ignore a file being sent you can use the .gitignore and adjust it if you want to send later, the .gitignore is an editable file at any time and you use it as you wish.

Add:

 config.php

Besides not sending, if there is any config.php in the repository it will be removed from there.

0

Add only what you’ve changed:

git add -u

Sumario

git add -A   Tudo que estiver em staging
git add .    Tudo em stage, e modificados 
git add -u   stage modificados e deletados, novos ignorados.
  • But config.php I changed, but I don’t want to send it. I don’t always need to send it.

0

Make the normal addition and ask for a rewind of the config.php.

git add -u
git reset -- config.php

Browser other questions tagged

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