Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude files for pushing

I have remote server with a git and local development machine. I need to don't send some files from my working directory on a server but stay it on version control of my local git. Let's say I have the following files on my local dev machine.

assets
   |-css
   |-js
compiles
   -css
   -js
index.html

All files are on version control, but when I need to make push I don't want it for 'assets' folder. How can I do that?

EDIT: Let me explain the situation. I'm a single developer and I do concatenate and minimize of my aseets files into compiled folder. So I don't need to push assets folder because production code uses compiles.

like image 753
Erik Avatar asked Mar 04 '13 06:03

Erik


3 Answers

I have found 2 answers to this:

  1. For a few files:
    git update-index --assume-unchanged FILE

  2. For many files/directories, or more permanent for that environment, or to share file list across environments:

    • Instead of using .gitignore, which will remove it from all version control, the file or folder can be added to : .git/info/exclude.
    • If one wanted to pull all of the repo from the repo to local or to another server (like staging), then another local clone can be made but without the local /exclude so it will grab everything.
like image 191
Mike Avatar answered Oct 23 '22 21:10

Mike


The simple answer is No, you cannot have different set of files on a given branch when you push a repo from local to remote.

Like others mentioned, you should be able to use .gitignore to exclude the assets directory totally from version control (on both local and remote repos):

# Your repo's .gitignore
/assets/*
like image 31
Tuxdude Avatar answered Oct 23 '22 21:10

Tuxdude


You can edit .gitignore. if you want to only works in local. You can edit .git/info/exclude like this

.git/info/exclude

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
./assets/*

OR

.gitignore

./assets/*
like image 3
Adem Öztaş Avatar answered Oct 23 '22 20:10

Adem Öztaş