Git setup used on several computers

I’m new to git and am not sure this will work but wonder if someone has done this and can help me.

I have uploaded all my userfiles (.zsh*, .bash*, etc.) to my git remote repository thinking that I could setup git or copy my git setup from my original computer and then when I get to the new computer to setup a user there, I could git fetch the files to the new computer and I would have both computer users look the same and work (that’s the key)! LOL

Can I copy the .gitconfig, .git/ and /etc/gitconfig files to another computer and just fetch the remote files to my computer? within the .gitconfig file I changed the /Users/joe/… to ~/… That seems to work just fine on the original computer but not on the new computer.

Ultimately I want to tar up a few files (including the git setup/config files), copy that tarball to the new computer, extract the files into the home directory and then do a git fetch to bring the local files into sync with the github repository. Hope I explained this well enough.

Can anyone point me in the right direction?

Thanks in advance for your help.


Storing your configuration (often called “dotfiles”) in a repository is a fairly common strategy. You can read about the practice, find links to tools to help, and see some people’s example repositories on Most people store their dotfiles in a repository named, appropriately, dotfiles. Here’s mine:

Hi Lee:

I am not sure what I did, but I have it working with my ${HOME} directory able to push and pull to origin master. I have all my machines now setup to check if there are any outstanding add/commit/push needed and then warn me and if not, to a git reset --hard; git pull origin master.

That seems to work just fine and dot files are download as needed.

Have I done something that is a no-no? I am using zsh and powerlevel10 theme and I notice that I don’t see Master show up on my prompt when I am in my home directory. Not sure this is necessary but wonder if there is a land mine out there I am not aware of.

I am sticking with git for right now until I get a better understanding of what happens with my remote repository.

Is there an absolute reason my I need to do something special with my dot files? They seem to be working ok now. Any suggestions?

Thanks for responding to this novice.

1 Like

Great! I’m glad to hear that things are working for you :grinning:

No, you haven’t. If it works for you and you generally understand how things fit together, those are the main goals, in my opinion.

One drawback to how you’ve organized your system, if I’m understanding correctly, is that you essentially have your entire HOME directory as a repository. The thing that might bite you with this setup is that you have to be extra careful to not commit anything else in your HOME directory into your dotfiles repository. For example, if you store general documents or data files in subdirectories off of your HOME directory, you wouldn’t want to get them mixed up with your dotfiles necessarily.

Because of this risk, I would also not recommend making your dotfiles repository public on GitHub like I’ve done with mine. Having a private dotfiles repository isn’t bad or anything, but I know that I’ve learned a lot by being able to share a link to my dotfiles and discuss things easily with colleagues and friends.

For these reasons, many people use some sort of system or automation to clone their dotfiles repository onto their machine somewhere under the HOME directory and then symlink the configuration files into the HOME directory. This does introduce a bit of complexity to the system though, so if that’s more than you want to dig into right now, that’s absolutely ok :grinning:

I’m happy to help! We all had to start somewhere :+1:

Can you take a look at my repository at josaladino2/userfiles and tell me if you still think it should be private?

Thx for your response. :grinning:

Taking a quick look, the fact that the .ssh directory is included in your repository is a big risk. Because you could accidentally commit an SSH private key and expose anything that you have secured using that SSH key :grimacing: So I think a good first step would be to make the repo private. But investigating some of those tools mentioned on the dotfiles site might be helpful to prevent this class of problem in the future.

Thanks so much. Will do.

1 Like