versioning different directory name from repository - windows

I have a local directory at my/local/directory/ with the files I wish to commit to the repository named differently than 'directory'. Is it possible to do this and if so how in the command line (windows)?

Perhaps you should read the Git manual first. You can name your directory as you like. The important think is the .git folder insight your directory.
If you have no git repository then you should initialize a new one and copy your files to that directory.
http://git-scm.com/book/en/v1

Related

Using git submodules as junctions in Windows

If a submodule's directory is a junction (Windows), git doesn't detect it as a repository and cannot work on such submodule.
For example, imagine a repository root is in c:\src\root, and that has one submodule subrepo, that is a junction to another drive. So c:\src\root\subrepo links to d:\submodules\subrepo.
If you try any git command on c:\src\root\subrepo you will receive an error message like
$ git pull
fatal: not a git repository: d:/submodules/subrepo/../.git/modules/subrepo
How can I solve these issues?
As you see, the problem is that git resolves the junction and works on the destination directory, instead of using the original path.
To solve the junction problem with git and submodules, it is enough to make a second junction, but in reverse way, to the .git directory of the parent rep. This should be a sibling of the subrepo directory, so it can be found when constructing the ../.git/ relative path.
d:\submodules\.git ==> c:\src\root\.git
c:\src\root\subrepo ==> d:\submodules\subrepo
Note that this may be a mess if you have different set of submodules, so in this case just group them into the same directory to avoid conflicts with duplicated .git directories.

Is it possible to include .git folder

I want to put my setting files in to the Git repository so I can sync them between my computers. I have the following folder structure:
d:\settings\
.git
plugins\
.git
other_things\
So, settings and plugins are separate git repositories. To track plugins folder without using submodules, I run the following command as per this post:
git add plugins/
Everything was fine, I was able to 'see' the files from plugins folder within settings up until I tried to sync it to my other computer, where plugins folder was missing its own .git directory.
Is it possible to include (exclude from .gitignore) .git folder via .gitignore somehow? I tried to use something like:
!..\.git
but it didn't work.
Thanks.
You should use submodule or subtree for that purpose. You can read more about submodules here:
http://git-scm.com/docs/git-submodule

Why are these files not ignored by git?

My .gitignore file contains these lines :
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
But the following file is still tracked
/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
Why is it so? How can I fix that?
PS: If I had MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger, the files are ignored. But I don't understand why it does not ignore them without this "hack".
EDIT 1
Contrary to what is said in one of the answer, the pattern
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
works !!! I mean, the files under /xcschemes are tracked.
See also the post Git ignore file for Xcode projects, where I get this .gitignore file.
EDIT 2
My Git version is 1.8.3.4 (Apple Git-47).
EDIT 3
When I git check-ignore this file, here is what I get
fatal: Not a git repository (or any of the parent directories): .git
But the fact is that a parent directory is a git directory...
EDIT 4
When I git check-ignore --no-index -- this file, here is what I get
[MT] PluginLoading: Required plug-in compatibility UUID 37B30044-3B14-46BA-ABAA-F01000C27B63 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeSnippetsHelper.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2014-02-10 10:03:50.856 xcodebuild[1496:d07] XcodeColors: load (v10.1)
2014-02-10 10:03:50.859 xcodebuild[1496:d07] XcodeColors: pluginDidLoad:
fatal: Not a git repository (or any of the parent directories): .git
EDIT 4bis
From the root folder :
if I don't use the no-index option, there is no reply to git check-ignore.
if I use the no-index option: I get the error error: unknown option 'no-index'...
Strange ;-!
First, you can do a git check-ignore (git 1.8.3.3+) to see what rule is ignoring your file (assuming it wasn't in the index in the first place)
Second, read ".gitignore exclude folder but include specific subfolder":
It is not possible to re-include a file if a parent directory of that file is excluded. (*)
(*: unless certain conditions are met in git 2.8+, see below)
Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
So the file of xcschemes wouldn't be un-ignored anyway.
You needed to ignore parent folder per parent folder.
But a better approach is to ignores files only, and then exclude the folder:
xcuserdata/**
!xcuserdata/**/
!xcuserdata/**/xcschemes/**
Remember:
You need to exclude folders from the gitignore rules before being able to exclude files.
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
Nguyễn Thái Ngọc Duy (pclouds) is trying to add this feature:
commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
However:
The directory part in the re-include rules must be literal (i.e. no wildcards)
So that wouldn't have worked here anyway.
Adding file names to .gitignore helps prevent you from adding the files unintentionally.
If you do something like git add . to add a folder full of files to the repository, the files (or filetypes) ignored in .gitignore will not be added.
They would have to be added by using the -f flag with the git add command.
It will not change anything if the files are already tracked.
You can stop tracking the files by using the answer to the question:
Remove a file from a Git repository without deleting it from the local filesystem
edit: After rereading the question a few more times, I think you may be having roughly the same issue that was addressed in this answer:
.gitignore - ignore any 'bin' directory

How to point gitbox/git to different local directory

Hi guys I have a remote repository cloned locally, Because my new changes have saved it to a different directory (workspaces in eclipse) I want to point git to the workspace directory rather than the other directory, how do I do this? Gitbox doesn't seem to have any options, and I can't see the .git folder
In your WORKSPACE do
git init
and then from where you pulled your copy initially. Do
git pull /path/to/your/workspace/project/dir

TortoiseHg change default .hg folder location

Is it recommend to change the default .hg folder location to a central place? Instead of having the .hg folder stored under working directory. Since I have accidentally shift-deleted the working directory and lost all commit history.
Is there any way to change the default .hg folder location in TortoiseHg?
Or any recommendation on backing up the repo? And how?
AFAIK, changing the location of the .hg folder is not possible. The presence of a .hg folder indicates that a given folder is a HG repository.
Even if it was possible to move the .hg folder itself to another location, there would still have to be some information in your working folder where your actual .hg folder is. So if you would accidentally delete your working folder, you'd also lose the path to the real .hg folder. Same problem :-)
Backing up a repo is easy in distributed version control systems like HG.
Make a clone somewhere (on a server in your network that's backed up regularly, or if you're at home, use a Bitbucket account) and push to it regularly.
I can think of two possible solutions, one I recommend, and one I don't.
The solution I don't recommend relies on your file system having Hard Links. When you create a new project, you could move the .hg directory to somewhere else on the file system, and set up a hard link to it in your working directory. You then essentially have two references on the file system to the same .hg directory, so if you delete one it will still exist.
I have done similar things on my gaming PC to have all savegames stored in subdirectories of a single \savegame directory.
However, a much better solution, and one that I would definitely recommend is as follows:
Have a directory (for example C:\HG) in which all "base" repositories sit. These are not working repositories, and would not have a working directory other than "null". When you create a new project, your first step would be to create a new empty repository in this base area:
hg init C:\HG\myNewProject
You now don't need to touch that repository other than to back it up (I use SkyDrive).
Then in the place you do all your work, you create a clone of that repository:
cd C:\WhereIWork\Projects
hg clone C:\HG\myNewProject myNewProject
Creating the clone automatically creates a link between your working repository and the one in C:\HG : any work you do should be regularly committed and pushed.
And there you have it - a backup that you never need to touch unless you delete your working directory by accident and need to re-clone.

Resources