How to Create and Push to a Local Git Repository

by | Sep 18, 2018 | Other | 0 comments

I want to store this one for later so I’m posting it here. If you find it useful feel free to link to it.

I wanted to version some files I’m working on but didn’t want to use a git service like BitBucket, GitLab, etc. mainly because they are huge and I don’t want to wait for them to upload all the time or pay money for that.

In order to do that I created a git repository on a separate hard drive on my system. The first step is to initialize this.

I found help with doing that here.

From within Git Bash or whatever you happen to be using type these commands wherever you want to store your git repository:

git init --bare --shared=group local.git
cd local.git
git config receive.denyCurrentBranch ignore

See this answer from just above the other one for a description of what those commands do.

Also note that instead of the first command, since I’m working on my own, I can just type:

git init --bare local.git

Next, in your working folder where you have your files run these commands:

git init
git remote add local E:\local.git
git add -A
git commit -m 'Init'
git push local master

And that is it!

If you want to store your local.git folder in a subfolder then you can change E:\local.git to file:///e/subfolder/local.git. You can change it in your .git/config file directly if you like.

Now whenever you want to save your changes just run the last 3 lines again with a new commit message and hopefully it will go ok. If not then you may have some more digging in git to do.

Hosting Recommendation

Hostinger - The Secret Weapon of Successful Site Owners

There's a reason I recommend Hostinger. After testing dozens of hosting providers, only Hostinger delivers the perfect combination of:

🔥 Blazing-fast load times
(essential for performance)
🛡️ Rock-solid uptime
(your sites earn money 24/7)
🔒 Free SSL certificates
(builds trust instantly)
💾 Automated backups
(your business is always protected)
👨‍💻 Expert support
(problems solved in minutes, not days)
⚙️ One-click WordPress setup
(seamless integration guaranteed)
💰 Starting at just $2.99/month
(premium hosting that won't break the bank)

Use my link or referral code
MILLIONDOLLARS to get 20% off !