How do I sync a (different named) directory with an existing github repo? - github

I want to modify a repo from two sources: windows OS and Ubuntu OS (Dual booting on a laptop). The repo contains files from my Arduino library directory (I'm using the repo as a place to keep changes to the library the same across OS).
Is it possible for me to get the content of the repo without having to rename the arduino library directory name (Arduino software looks for a folder called 'libraries' so I can't change its name).

When you clone a repo, git defaults to placing it inside a folder with the same name as the repo, but this is not required. You can name it whatever you want. So you likely want to run some git clone git#github.com:/your/repo libraries to get the repo content in that path.
You can also rename the repo folder after cloning if you already have it but need the path to be different on your system.
I'm not sure if you have everything in libraries checked in or not, but if you have only certain directories in git you might be able to keep the repo somewhere else on disk and symlink from libraries/library1 -> /path/to/your-repo/library1

Related

Eclipse Workspace on a network folder (UNC path)

I am working on a project which has GitLab repository and the local repository is on a network folder so I wanted to create an Eclipse Workspace on that folder as one can share the project with the other team members but when I tried to build the project I got an error message which says that eclipse workspace can't be a UNC path, so my question is, is there any work-around way I can do this, for example is there any way I can let the OS (Windows 10) link a local folder to the one on the network so that every member would do the same and work on his own local folder and it will be automatically edited in the network folder?
Thanks
No, this is not possible since everyone needs their own cloned Git repository to work with.
For instance, switching the branch or staging files are per repository and would therefore affect everyone. When you clone a Git repository without the bare option, there will be a so-called working tree which is the location where the currently checked-out files are and this folder is not copied but mapped into your workspace. Everyone would not have a copy of those files but working with the same files.
Besides the editing conflicts you would have, another disadvantage of having a Git repository on a network drive is that it would be slower. Therefore one would not want to have this even if it were possible to have Eclipse projects on a network drive.
But since in most cases a Git repository including the working tree takes less disk space than in SVN the working copy of the same, it should not be a problem if everyone has a locally cloned Git repository.

EGit working directory not under the local repository

The working directory should be visible on a WebDAV server and none of the parent folders should contain the repository itself.
I want to separate totally the folder for .git and the working directory (on a different drive, clean from project files and others).
Using Eclipse EGIT, the repository creation allows set of working directory (Target Location) within a path within the repository.
No way found to set GIT_DIR or working_directory within Eclipse. Linking not an option (Windows)
The project .location contains the place within the repository (and that is a binary file anyway), so that should be configurable.
Is there any way to move the working directory to a totally different place?
Is there a configuration option I have missed?
After editing the files, do I really have to push all to the server, then commit to git?
To summarize what has been written in the comments, EGit does not support Git repositories whose work directory is at a different location than the .git directory. I.e. the core.worktree configuration setting is not taken into account.
See also this open enhancement request: https://bugs.eclipse.org/bugs/show_bug.cgi?id=433451

How do I store projects that share a common shared driver on Git

I'd like to create Git repositories for some of my existing STM32 embedded C projects that I'm developing with Eclipse.
Currently I have two separate projects in their own folders, and a common folder containing ST's official STM32 Cube peripheral drivers (.c and .h) files that both projects use.
The driver folder shouldn't change (except when new versions are released) but the project files will be edited as I develop them.
How should I place them on Git? Should I:
Have three repos (one for each project and another for the drivers)?
Have two repos and change my project structure to place the drivers with both projects?
Something else?
The first option seems OK, but if I don't clone both the project and driver repos, and do them to specific locations, I can't see how I would configure Eclipse properly.
The second seems more hassle free but redundant (it won't be as easy to update all projects to use new drivers as they are released, and it will use more server space).
EDIT: Just to clarify, I'm not using the STM32CubeMX software. I'm simply using the STM32CubeF4 peripheral drivers, which are basically just embedded C .c/.h source/header files for the chip's internal peripherals (and possibly a few .lib library files for DSP calculations). See the "download" button at the bottom of this page for the .zip archive (current version is 1.4.0): http://www.st.com/web/en/catalog/tools/PF259243
If you use a common driver in several other repos, it looks like a job for git submodules.
You have three separate repos, for example on your server, and both projects include the driver code as a submodule. What is stored in each project repo is:
an URL to the driver repo (on your server)
which commit of the driver repo is to be used
the path where to put the driver clone, relative to the project repo
After cloning a project repo, you run git submodule update --init, and the repo at URL is cloned into the relative path, and its commit is checked out.
git submodule add --name <driver> /server/src/driver.git driver
(/server/src/driver.git is URL, driver is path. <driver> is just an optional reference to ease future work with submodules. Don't use it if it is the same as path)
git submodules feel a bit cumbersome at first. For example, cloning or checking out commits in the parent (project) repo does not make the submodules working files up to date. You have to manually git submodule update for that.
You will end up with two clones of your driver, one in each project's working files structure. But this is not really redundant, as they are clones of a common driver repo on your server.
For every update of your driver, you push the driver changes to your server. To update to the latest driver version in another project, you go to that project's submodule, do the usual git push (you might be in detached state, in which case you need to checkout master first). The update will show up in the project's (not the submodule's) git status, which will tell you "New commits" in the driver submodule. What has changed is which SHA1 is checked out in your submodule; commit the changes in the project will only update which submodule commit is to be checked out.

Multiple "upstream" files in one github repo

I've repos with various configuration files, like .vimrc, _vimrc (for windows), or .bashrc. I'd like to create one repo that holds all of them, so I can easily set up my environment on clean machines. I'd like linux / windows specific files to be in different branches (?), so that cloning on linux would not download windows files.
How do I do that, assuming all existing repos are on github and the resulting repo should be on github too?
Is there a way to force git to just download files from a branch and save them in a directory, without creating a local repo? For .bashrc it'd be faster to just download and save to ~, instead of cloning and then copying that file to home dir.
Maybe something like dropbox would be better for this?

IDE independent mercurial repository

I've just recently started using Mercurial and would like to keep my projects as independent from IDE as possible.
Therefore, I would like to only include my src, test src, and doc directory in the repository.
I've managed to only book these directories into the repository by ignoring all project related files.
The problem is that when I then clone it onto another system, Netbeans 7 wants to create a new project from these files. It does so by creating the project file inside of the repo instead of on the cloned name, since it cannot create a project on a directory that already exists.
Is there a standard way of booking in these folders and then when cloning them to create a project from them?
What about creating the project in Netbeans first and the cloning the files into it?
To avoid Mercurial complaining about the clone destination not being empty, use init + pull in the project directory instead of clone, this is equivalent:
$ cd myproject
$ hg init
$ hg pull -u http://example.org/myrepo
You could also just clone into a separate directory and then move all files (including the hidden .hg directory) into the Netbeans project. You could even just move the .hg directory, because that’s really all that Mercurial cares about.
Although actually I’m surprised you can’t start a project that is already on the file system. I’m not familiar with Netbeans, but can’t you import an existing project from the file system?