git

Suppose, we have one remote server for remote repository, remote1 and two local repository machines local1 and local2, where two different developer1 and developer2 are working separately on the same project. Now, the whole process goes like this.

Assumption, you have created user called ‘git’ and working under /var/git-repo directory in remote1 machine.

 

1. Create remote repository in remote1 machine:

2. Now, developer1  create its local repository for project-name, add files, commit to local repository and finally pushes to the remote1 machine:

3. Next, developer2 clone the remote repository to the local machine, add some files , commit to the local repository and he also finally pushes to the remote repository:

4. Again, developer1 wants to make some changes, before that he has to pull all files from remote1 machine and make uptodate before adding some files to remote1 machine:

5. Accidentally, developer1 and developer2 are working on same file, so developer2  now undo the changes he made, pull it from remote1 and only changes on it:

6. Again, developer1 wants to work in separate module of the project, so he create a separate branch and switch to that branch, add some changes to that branch1 and finally merge the branch1 to master branch.

He can merge the branch1 to master branch  in two ways:

Option1:

Option2:

 

7. If developer1 has finished developing the module1, then he can delete the branch1, and push to remote1 machine:

 

8. Suppose, developer3 come in the middle of the project, who likes to work using Eclipse IDE. So, what he does is,

i. Open the Eclipse

ii. Select the Git perspective from window menu

iii. Then, clone the project from there to local repository

iv.  Next, he create new project, suppose its a PHP project, selecting the existing clone directory

v. he switches to  PHP perspective, add some files, commit there and finally pushes to the remote1 machine using Eclipse Git tools.

9. Some frequently useful git commands:

10. If you like to ignore some files

11. if developer1 wants to publish in this local apache2 webserver, then does this in post-commit file inside hooks directory:

And, make the post-receive executable:

12. If it is to be published from remote1 machine, we do this in post-receive file inside hooks directory:

And, make the post-receive file executable: