Clement
Clement

Reputation: 79

how to tell 'git' not to track the link itself but its content

We have a git repository where we have a subfolder called 'shelves' for test purposes where we need to maintain a certain folder structure inside it for our data files. These folders are populated with content that must be tracked by git.

Now at a the same level of unix hierarchy we have a link that point out the current test to the relevant folder. The link may change from time to time to use a test or another.

ls -l current lrwxrwxrwx. 1 xxxx xxxx 30 Apr  3 09:18 current ->
shelves/test1/tb

Folder hierarchy:

shelves/
├── test1
│   ├── rtl
│   │   └── vhdl
│   └── tb
├── test2
│   ├── rtl
│   │   └── vhdl
│   └── tb
└── testn
    ├── rtl
    │   └── vhdl
    └── tb

The problem is quite simple: we don't want git to track the link itself but the content of every folder under 'shelves' must be tracked.

We need the link to be on 'git' but not tracked because when we git clone the link has to be present. If whenever we use to put 'current' inside .gitignore when we 'git add' some file under the structure we got that message:

The following paths are ignored by one of your .gitignore files:
shelves/test1/tb Use -f if you really want to add them. 
fatal: no files added

Any trick guys? We know we could use '-f' but can we work around this by other means?.

Note that our 'git' release is pretty old and we don't think we can't update so easily (CentOs 7.3) because of dependencies.

git version 1.8.3.1

Upvotes: 1

Views: 245

Answers (1)

djehrame
djehrame

Reputation: 556

Check out git submodule - this would work as long as you are able to have your test files in a separate repository.

You can have a git submodule either fixed at a certain commit, or point it at a branch and have your repo automatically update.

https://git-scm.com/book/en/v2/Git-Tools-Submodules

Upvotes: 1

Related Questions