create a sample project in git

This is a sample project created to learn basic git commands such as clone, commit, push, pull and merge.

#Project Name: shop
#Bare Repo Path: /home/repos/shop.git

1. Create a bare repo
git init –bare /home/repos/shop.git

#Get a clone by user ‘Anna’
mkdir /home/Anna/shop
cd /home/Anna/shop
git clone /home/repos/shop.git .

#Create a file called index.php  and add some contents.
#Add this to git tracking
git add index.php
# Commit the changes to local repo
git commit -m “adding index.php”
#push the file to bare repo ( Centralized Reop)
git push origin master

#Get a clone by user ‘Maria’
mkdir /home/maria/shop
git clone /home/repos/shop.git .
# Now Maria should be able to see index.php file

#Deal with Git merge
Let  Anna makes some changes and push it again to the main repo. And assume Maria does not have latest files from main repo. If Maria edits the index.php file and try to push to main repo, it will not allow to push the changes. Error message will be like ‘error : Merge the remote changes before pushing again’

#Following steps will get latest copy from main repo and merge it with local copy.
git pull origin master
git merge
git commit “adding Merged index.php” index.php
git push origin master

Note: There is chance that you may see that git cannot merge it by itself and in this case we will need to manually do it. Then,
git commit -m “adding Merged index.php” -a
git push origin master