15 Jul 2011
Install Git on both Server and Client machines.
if you’re on a Debian-based distribution like Ubuntu, try apt-get to install Git:
apt-get install git-core
Preferred way of doing GIT on server:
In order to initially set up any Git server, you have to export an existing repository into a new bare repository — a repository that doesn’t contain a working directory.
This is generally straightforward to do. In order to clone your repository to create a new bare repository, you run the clone command with the –bare option. By convention, bare repository directories end in .git, like so:
git clone --bare my_project.git
output:
Initialized empty Git repository in /var/www/my_project.git/ warning: this creates an empty git repository.
On Client machine
Step 1 on client machine clone the remote repository using,
git clone [email protected]:/var/www/my_app.git
output: Initialized empty Git repository in /var/www/my_app/.git/ warning: You appear to have cloned an empty repository.
Step 2 create a Readme file inside the my_app folder and add it to the stage and commit it,
git add Readme
git status
git commit -m "Initial commit adding readme file"
Step 3 check the remote repository information using
git remote -v
output: origin [email protected]:/var/www/my_app.git (fetch) origin [email protected]:/var/www/my_app.git (push)
Step 4 check your branches in local repository
git branch
output:
- master
Step 5 lets create a new branch that reflect new pre in the project.
git checkout -b develop master
output: Switched to a new branch ‘develop’
Step 6 again, check your branches in local repository
git branch
output:
- develop master
Step 7 lets switch to master branch
git checkout master
output: Switched to branch ‘master’
Step 8 adding remote path to git
git remote add origin ssh://[email protected]/var/www/my_app.git
Step 9 pushing local master pre to remote repository
git push origin master
Step 9 same way push the develop pre to remote repository
git push origin develop
Step 10 to fetch the latest pre from the remote repository
git fetch origin < branch name >
Git Tips: To remove a file(s) from Git
git rm --cached < file path >
Looking for comments?
I don't have comments on this site as they're difficult to manage and take up too much time. I'd rather concentrate on producing content than managing comments.
Since there are no comments, feel free to contact me ✉️ contact me instead.