0

cat .gitignore:

...
*log
...

I wanted to ignore all .log files, except now for cli.log. How can I make this an exception?


Original Problem

"1 Pushed file isn't in remote repo, but all other files of same commit do | Git"

I have been successful at pushing changes to files... except cli.log.

I have tried solutions here with no luck.

Terminal:

me@LAPTOP-G1DAPU88:~/.ssh/.../data_simulator$ git checkout simulate_data
Already on 'simulate_data'
Your branch is up to date with 'origin/simulate_data'.
me@LAPTOP-G1DAPU88:~/.ssh/.../data_simulator$ git pull
Already up to date.
me@LAPTOP-G1DAPU88:~/.ssh/.../data_simulator$ cd data
me@LAPTOP-G1DAPU88:~/.ssh/.../data_simulator/data$ ls
Citizenship.csv  cli.log  currency_symbols_map.json
me@LAPTOP-G1DAPU88:~/.ssh/.../data_simulator/data$

Git:

data_simulator/data:
    Citizenship.csv
    currency_symbols_map.json
torek
  • 448,244
  • 59
  • 642
  • 775
  • 1
    Check `.gitignore` for patterns that would match, such as `*.log`? – Jiří Baum Jul 14 '21 at 13:00
  • `cd ..` a few times, `cat .gitignore`. 1 line says `*.log`. How do I make an exception for the name of my file `cli.log`; and ignore every other `.log` file? –  Jul 14 '21 at 13:04
  • 1
    https://stackoverflow.com/search?q=%5Bgit%5D+ignore+all+file+type+except – phd Jul 14 '21 at 13:09
  • You guys are awesome. Thank you. Can one of you "accept" the suggest post as the answer at all? –  Jul 14 '21 at 13:11
  • There is actually no need for you to add anything in `.gitignore` for that file. Just ignore all `.log` files, and add **with force** the file. And that's it. – eftshift0 Jul 14 '21 at 14:30
  • 1
    @eftshift0: that method does work, but I generally dislike it on a sort of procedural or categorization basis: I think that `.gitignore` should work correctly if you accidentally run `git rm --cached -rf .`, then realize that was a mistake and run `git add .`. Force-adding one file to bypass `.gitignore` means that this "repair my mistake" trick wouldn't work. – torek Jul 14 '21 at 22:23
  • Makes sense.... but you do check `git status` before committing, right? XD You should be able to see that the file is showing up as deleted in that case (after adding everything back). – eftshift0 Jul 14 '21 at 22:33
  • Interesting pointers guys. Thank you for the knowledge share –  Jul 15 '21 at 08:12

0 Answers0