Can't Hard Link the gitconfig File

Asked
Active3 hr before
Viewed126 times

8 Answers

90%

1 git config breaks hard links. Use a symbolic link instead. – William Pursell Aug 2 '12 at 22:22 ,Thanks to Dietrich Epp's answer and advice I have decided to approach this problem from a different angle by creating the repository at the root of my filesystem, and using .gitignore to track only the files I am interested in.,I am attempting to create a git repository to store all of my dotfiles and config files. My idea was to simply create hard links to all of the files I cared about and store those links in their own directory that I could turn into a repository.,In the meantime, have you considered doing the links in reverse? Create your repository full of config files, etc, and then in the place that you actually use your files, create a hard link to the 'real' file, which sits in the repository.

My .gitignore file now looks like this:

/*

!/etc/
/etc/*

# etc files
!/etc/rc.conf
!/etc/asound.conf
!/etc/mercurial/

!/home/
!/home/matt/
/home/matt/*

# Home files
!/home/matt/.xinitrc
!/home/matt/.gitconfig
!/home/matt/.bashrc

# Vim files
!/home/matt/.vimrc
!/home/matt/.vim/
.netrwhist
88%

I changed the symbolic link to a hard link and somehow this works ok. I was able to verify this by opening the .gitconfig link within Windows; when using a symbolic link the file contained binary data however the hard-linked file contains the content as expected.,If you were modifying the file ( $ nano ~/.gitconfig ), you would put this into your file instead:,For those hitting into this issue (I believe it's due to crashing out git mid init?) in windows, if you have a recent backup of the config file from your git repo's .git/ folder you can fix it by replacing the existing with it (any ref's added since the copy will obviously need re-adding) - not at all ideal but better than loosing all the commits.,I have a habit of symlink-ing the config files in my home directory to a nested Git repository for maintaining the files across my multiple development environments. It turns out that Cygwin's implementation of a symbolic link doesn't make much sense to Git running under Windows.

If you were modifying the file ( $ nano ~/.gitconfig ), you would put this into your file instead:

[user]
name = WilliamQLiu
email = [email protected]
load more v
72%

If false, symbolic links are checked out as small plain files that contain the link text. git-update-index[1] and git-add[1] will not change the recorded type to regular file. Useful on filesystems like FAT that do not support symbolic links.,If the pattern starts with ./, it is replaced with the directory containing the current config file., If the pattern starts with ./, it is replaced with the directory containing the current config file. ,A list of all available configuration variables can be obtained using the git help --config command.

git config [<file-option>] [--type=<type>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] name [value [value-pattern]]
      git config [<file-option>] [--type=<type>] --add name value
            git config [<file-option>] [--type=<type>] [--fixed-value] --replace-all name value [value-pattern]
                  git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get name [value-pattern]
                        git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get-all name [value-pattern]
                              git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] [--name-only] --get-regexp name_regex [value-pattern]
                                    git config [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch name URL
                                          git config [<file-option>] [--fixed-value] --unset name [value-pattern]
                                             git config [<file-option>] [--fixed-value] --unset-all name [value-pattern]
                                                git config [<file-option>] --rename-section old_name new_name
                                                   git config [<file-option>] --remove-section name
                                                      git config [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list
                                                         git config [<file-option>] --get-color name [default]
                                                            git config [<file-option>] --get-colorbool name [stdout-is-tty]
                                                               git config [<file-option>] -e | --edit
load more v
65%

Git list can help you find the gitconfig file.,If developers aren’t exactly sure where the various Git config files are supposed to be located, they can always run the following command in BASH:,How to find gitconfig.,Do you suspect that your attempt at microservices left you with distributed monolith application design? There are some telltale ...

/c/
where is gitconfig(examaple)
$ git config--global--edit
$ git config--system--edit
$ git config--local--edit

If developers aren’t exactly sure where the various Git config files are supposed to be located, they can always run the following command in BASH:

sudo git - c core.editor = ls\ - al config--system--edit
load more v
75%

You might have a hard time managing many cats, but when it comes to Git profiles there is something you can do.,We're all set!  Now you will have three Git files in your home directory.,Create the global .gitconfig file in your home directory if it doesn't already exist. Then add all the profile directories as an entry like in the example below.,The idea is to segregate the repos on your machine into multiple directories by separating the profiles you want, and then define a .gitconfig file per profile.

[includeIf "gitdir:~/personal/"]
path = ~/.gitconfig-personal [includeIf "gitdir:~/work/"]
path = ~/.gitconfig-work
load more v
40%

Retrieve the location (and name value pairs) of the system git configuration file:,Retrieve the unique locations of all git configuration files:,Retrieve the locations (and name value pairs) of all git configuration files:,The system configuration has also a fixed path on Windows, relative to the installation directory: etc\gitconfig

git config--list--show - origin
load more v
22%

So I’ve finally found a solution that takes the best of both: put the repo in a subdirectory, and instead of symlinks, add a configuration option for “core.worktree” to be your home directory. Now when you’re in your home directory you’re not in a git repo (so the first problem is gone), and you don’t need to deal with fragile symlinks as in the second case. You still have the minor hassle of excluding paths that you don’t want versioned (eg, the “*” in “.git/info/exclude” trick), but that’s not new.

我使用所有我的配置和点文件(.bashrcprofile.ps1.emacs等)维护一个私有(private)的Git存储库。

在Windows上,此存储库存储在C:\git\config下。大多数应用程序期望文件位于其他位置,因此我在存储库和期望位置之间添加了硬链接(hard link)。

例子

在Linux上,.emacs位于~/git/config/.emacs中,但是emacs希望它位于~/.emacs中。我跑:

$ sudo ln - s~/git/config / .emacs~/.emacs
load more v
60%

Get into a habit of editing configs, and adding then, committing changes. Push those changes back to your origin server periodically and pull/update when needed. I find that using Git is infectious and when I find a server not under Git config version control, I quickly go around adding its necessary configs into the repository. ,This article explains how I solved a couple of challenges of getting my initial environment and configs into Git—the first steps to using GitOps. ,Store production, test, and configuration in different branches and merge between them.,Easy to reuse configs - Just installed a new server and want to use 90% of a common apache configuration? Just clone the repo and copy the file.

My intention is to store all my configuration files for dnsmasq, httpd, and so on, all in Git. The configuration is sensitive, including usernames and passwords, so obviously a GitHub public repository isn’t the best idea. If you’re willing to pay for a private repository, go for it. I opted to create a repository on a dedicated server that I have on the public internet so that all other servers can connect to it. 

$ cd / opt /
   $ sudo git init--bare ServerConfiguration.git
load more v

Other "undefined-undefined" queries related to "Can't Hard Link the gitconfig File"