So i have folders like this
c:\projects\generic\
c:\projects\project1\
c:\projects\project2\
Each folder under projects are their own separate local git repository. A project may use one or more header files from the generic folder. If a project uses a header file, it needs to be right in the project folder, not a subfolder under the project folder. Also, I probably wouldn't want the latest and greatest, I'd want to pull it by tag so I could be sure I have a specific version of the file in use for that project.
How would I do that? Is this something that could be done with submodules? Is there a better way to organize the folders in this situation?
I'd want [...] a specific version of the file in use for that project.
Yup: submodules are for exactly that. A submodule is a nested repository, the using projects' commits record (only) exactly which (other) commit SHA they need checked out at the submodule's path, git submodule just does the chores of getting the right submodule commits checked out when you want.
If a project uses a header file [from another repository], it needs to be right in the project folder, not a subfolder under the project folder [... I'm on windows].
It's lucky these are headers, otherwise there'd be a problem with that combination. As it is, the compiler can chase the relative pathnames with a #include "relative/path/to/submodule/header.h":
repo
|--generic.h: "#include generic1/generic.h"
|--generic1
|--generic.h: the real thing
Related
I am using X-Code 10 as a C IDE. I am doing a group project and we must use GitLab to share the code. To work in Xcode there are a lot of files to make Xcode work, but none that I need to share with my partners who are using their own IDE and who just need the .c files we are working on. How do I make Git not upload ALL files and just the .c?
There are ways to handle the excludes for a git project. There is the .gitignore file where you can create rules for what files should be excluded from your project. This file will be tracked by git, so you and your teammates will be sharing this file.
For your own personal excludes, you can put them into the .git/info/exclude file. This will not be tracked by git and will affect only your own local repository. This is a good place put rules that are specific to your own workflow.
I have an existing C project with the following folder structure:
bin
proj
src
inc
doc
conf
When i launch Eclipse and create a new project the root project folder is polluted with:
.cproject
.project
Also the parent folder with:
.metadata
RemoteSystemsTempFiles/
A want to continue use Eclipse as an C IDE with a my custom makefile (or not) but I want all Eclipse related files and folders to be put inside the proj directory. I need Eclipse to debug ARM targets.
Is it possible? If not what is the next best thing?
I made a promise to myself to start a smooth transition from IDEs to vim with a custom makefile. I still need Eclipse to help me for debugging.
One step at a time...
The files .project and .cproject (and the .settings folder if it exists) contains the Eclipse-specific (general and C/C++) project configuration.
The .metadata folder is a kind of cache/temp folder (to store error/warnings markers, local file history, etc.) and also used to store your workspace preferences (most of Window > Preferences).
Files in a project are tracked and can cause changes in the .metadata folder. If the .metadata folder would be located in a project, this could end in an infinite loop.
You could use the workspace folder of Eclipse (which contains the .metadata folder) as part of your overall project folder and link instead of copy all files and folder that you want to see in Eclipse or that are required by Eclipse into your Eclipse project (you can also mark some files and folders as derived to stop them from being tracked and to make them less visible in Eclipse).
Note, do not share or move the .metadata folder (and derived resources). In contrast, .project, .cproject and .settings are intended to be shared.
I installed SQLite into my WPF project via Nuget. Then added the entire project to a remote repo. Then I cloned the project on another machine, and had a broken build.
x64\SQLite.Interop.dll was missing.
I'm puzzled why Git didn't include one file from my project. I checked the repo on BitBucket and confirmed it is not there. Git status reports nothing to commit, working directory clean
It added the x86 version, but not the x64 version, I can't imagine why.
(project)\x64\SQLite.Interop.dll Git ignored this file!
(project)\x86\SQLite.Interop.dll
You might want to check the .gitignore file at the root of the repo. If it contains for example x64, it would ignore this file.
There would be two main possibilities then:
edit this file to fit your need
or force this file to be added; ie: git add -f x64/SQLite.Interop.dll
However, committing binary files is often frowned upon. It's true in particular if you want to keep up to date with the latest package, hence if you plan to commit new versions of the dlls on a regular basis.
You might rather want to consider Nuget package restore feature. Basically the idea is that you commit a config file, and the client will automatically download the corresponding packages.
I've had a look at one or two similar questions on Stack Overflow, but they don't address what I am looking for exactly, unless I've missed it somewhere.
What I have is my own repo that contains custom boilerplate code. In my repo I'd like to include files from various other remote repo's (not my own). Thus when I'm ready to work on a new project, I can clone my repo, get my boilerplate code, as well as the files from the various other repo's I usually go to manually and download from. This way preferably the up to date versions are pulled as opposed to just copying these files into my own repo and having to update them every time there is a revision.
Is this possible to do simply using Git/GitHub?
Submodule is the way to include other repos.
And you now can define a submodule to follow a branch (git 1.8.2+), which means this will bring you the latest commits of said branch.
git submodule update --remote
I do that in my compileEverything GitHub repo, where I include the latest from Semantic-UI master branch.
That is because my .gitmodules looks like:
[submodule "Semantic-UI"]
path = Semantic-UI
url = https://github.com/jlukic/Semantic-UI
branch = master
I'm not particularly looking to include an entire repo/branch but just a select few files within one.
Example: Normalize.css Still possible to do?
No. It is best to:
include the full repo through a submodule (since the submodule pointer itself hardly takes any place in your repo)
keep in the parent repo symlinks to the files you need from that submodule.
That way, you see:
the files you want (symlinked to the same files from the subrepo)
the subrepo reference, that you can update at will.
lets say i have a qt project file (*.pro) and related files under a versioning system (git). The project is multiplatform and developing is performed on a lot of different ones as well. Developmers are both progrmmers and not programmers (matematicians, ecc) so i'd like to keep things as easier as possible for the person who cloned it (eg: avoid env variables).
The project is dependent on other projects whose are in an non-standard folder in the developer platform.
So i need them to edit the project file INCLUDEPATH += "absolute-path-to-external-stuff"
Problem is i'd like to put this single line in a file to be included in the .gitignore (remove it from versioning once uploaded) so that one can freely edit it without editing others when pushing to repo.
Should i use .pri files (and how? it seems they only are ok in subdirectories, cant find a reference) or is there a better pattern?
You can use a .pri file for that — a .pri is just a file that gets include()d by a .pro file.
Create a file in the project root called config.pri, containing the INCLUDEPATH addition
Add include(config.pri) to your main project file
Add the config.pri to your .gitignore
In the long run, you might consider using pkg-config to manage dependencies, since it integrates nicely with qmake.