Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

How to exclude .gitignore rules only once?

Make once init of my laravel 8 app on server(ubuntu 20) I need to upload some images under storage, which is excluded from git by .gitignore rules.

I do not like to remove .gitignore at all, but if there is a way to exclude these rules only once ?

Seems there is some force option, but how can I use it running command locally :

git push -u origin master

and on server :

git pull origin master

?

My root .gitignore:

# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
#     https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv


/public/js/laravel.app.js
/public/js/oneui.app.js
/public/js/tables_datatables.js
/public/css/oneui.css

composer.lock

package-lock.json

.env
vendor/
route_list.txt

Which is correct syntax ?

Thanks!

0 likes
4 replies
mabdullahsari's avatar

You need to learn how Git works.

Once you commit a file, then it will be remembered for the rest of the repository's life. There is no going back. Git is a stack of historical facts which cannot be altered.

SSH or SCP the file to the server instead.

Snapey's avatar

Why not put the images in a folder within public if they are static assets ?

mstdmstd's avatar

@Snapey But they are read in vue pages with url referenced to storage subdirectory

mstdmstd's avatar

Looks like adding -f key like:

git add -f storage/app/public/Photos/1/img-13.jpg

works in my case

Please or to participate in this conversation.