makeyourownmaker
makeyourownmaker

Reputation: 1833

How to add README.md on github but not have same README.md in home directory while using a bare git repository for managing dotfiles?

I manage my dotfiles using git in a bare repository. See article by Harfang Perch for details on this method.

It works great but I'd like to add a README.md to the root of the repository on github.

How do I add a README.md to the github repository root directory but not have that file show up in my home directories?

If I push a README.md to github then delete the README.md in my home directory this will result in

deleted:    README.md

messages from git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME status which I'd prefer to avoid.

As far as I'm aware github only renders README and README.md files in the repository root (and sub-directories but that's not relevant for this question).

I haven't seen other github dotfile bare repositories with README.md files but I've only checked 5.

Github wiki pages don't solve this problem unless there is some magic to display them in the root of the repository using a hidden .dotfile. Perhaps I'm grasping at straws but, is there any way to link and display a gist in the repository root directory on github?

I don't currently use gitlab but moving to gitlab, or a similar git hosting service, is a possibility if they have support for this that github does not.

Upvotes: 14

Views: 6739

Answers (6)

Simon Bakken-Jantasuk
Simon Bakken-Jantasuk

Reputation: 19

Look at the documentation here for README.md https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes

If you put your README file in your repository's hidden .github, root, or docs directory, GitHub will recognize and automatically surface your README to repository visitors.

If a repository contains more than one README file, then the file shown is chosen from locations in the following order: the .github directory, then the repository's root directory, and finally the docs directory.

So .github, / and docs/

Upvotes: 1

Biloubilou
Biloubilou

Reputation: 256

You can put your README file in a .github folder and it will be automatically detected on github to be displayed on your repo main view

Upvotes: 24

mrossman
mrossman

Reputation: 589

Although not ideal, one simple solution is to put your README and any other meta-files about your configuration into a tracked .dotfiles directory. You can then link to the README file in your repo's about section on GitHub.

An example of this setup: https://github.com/anandpiyer/.dotfiles

Upon trying this myself, I realized my repo itself is stored in a .dotfiles directory so the README gets mixed in with the internal Git files. However, placing it in ~/.dotfiles/README.md and adding/pushing worked as expected. You could try a different directory name like .about if you don't want it mixed in.

Upvotes: 2

LeGEC
LeGEC

Reputation: 52081

The Readme.md displayed by default on GitHub is the one in the master branch.

You could create a home branch that wouldn't have the Readme, and use that branch as a work branch.

You would probably want to merge to master on a regular basis, you could add one or two convenient aliases to do this in one go, either when committing or when pushing.


You could try to get clever with subtrees too.

Upvotes: 3

makeyourownmaker
makeyourownmaker

Reputation: 1833

The best I can do for now is to link to a gist from the About section.

The About section is displayed on the right-hand side of github repository pages.

Upvotes: 1

Alejandro Barrios
Alejandro Barrios

Reputation: 37

commit and push the correct readme file to your repository,

add the readme file in your .gitignore file and now u can change the readme file in your computer and commit your changes without any problem.

if git not ignore the readme file, try:

commit all your changes and run

git rm -r --cached . 

for reset the followed files on git

Upvotes: -4

Related Questions