How to Push to a Git Non-Bare Remote Repository

Git has two modes of remote repositories, Bare and Non-Bare. The Bare are those repositories which do not have a working directory while a Non-bare repository is just like any Git repository, it has a .git folder and the usual files.

Git is very flexible and dynamic. The remote repository can be on the internet and accessed using SSH, it can be on the local network or it can simply be on the same machine (a different path). In all cases the behavior of Git is more of less the same.

Lets open the terminal and begin.

Create a folder for local repository:

mkdir local

Create a folder for remote repository:

mkdir remote

Move into the local folder and create a repository:

cd local
git init
vim README
git add .
git commit -m "initial commit"

Now go to the remote folder and create a non-bare repository:

cd ../remote
git init

Come back to the local folder, and add the remote repository to its list of remotes:

cd ../local
git remote add remote /home/ahmad/Desktop/remote
git push -u remote master:updates

The changes have been pushed to the updates and now we need to merge them to the master of the remote repository:

cd ../remote
git merge updates
git log

To make another change:

cd ../local
vim README
git commit -am "another change added"
git push -u remote master:updates
cd ../remote
git merge updates
git log

Hopefully this worked 🙂

Advertisements

3 thoughts on “How to Push to a Git Non-Bare Remote Repository

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s