Working in different projects in group some time can be a little frustrating if taked in the wrong way.
What git do? Git is an open source distributed version control system designed for small and very large projects. Allows a groups of people to work on the same documents ( no metter if this is code or other kind of file ) at the same time, without conflicting with each other. This tutorial will help to understands the basics of git and how to use it.

Today exists a lot of online company and open source systems offering git service, the free one has the disadvantage to make public the source on internet so every one can view your proejcts ( like ), the payed company make your account private, so only authorized users can view the files.

How git works in the backend?
Theoretically the original copy of the project it is stored on a git server, and on it can access the group members downloading the last version and also updating with the modification they will made during time. Also if two or more members of the group work at the same file will be no conflict on the server.

Let’s start with same basic command in order to understand better how git works. Git it is available for Windows / Linux / Mac. I prefer working on Linux, later will explain also how to install it.

First of all lets install it
For Debian / Ubuntu / Mint
sudo apt-get install git
For / Fedora / Centos / Redhat
yum -y install git
If you have the project online on git server skip this step please
after that go to the folder you have stored the project and initialize it, means inside the folder project from terminal run
git init
git config "Your Name Here"
git config ""

If you have stored the project online this is the right step to follow:
git clone
Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch -r), and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.
After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any. This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.
git clone user@name_of_the_server/directory folder_name_of_project
Running this process from terminal need to be on the exact folder directory you want the project to be, on it will be created a sub folder (folder_name_of_project ), just enter on it from terminal. After this you have a git folder ready to send / receive data from server. Three basic command you will work most of the time are commit, push , pull
git commit -am 'Starting'
Record changes to the repository, every commit you made it is like a history, you sign the steps and the chnages you made one the project, i named Starting , you can name differently every time yoo make chnages. This command is a key on upload / download proces. If you do not commit the git proces will not recognise the changes you have made on the project.
-a -> Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.
-m -> Use the given <Starting> as the commit message.
You can also
git push origin master
Update remote refs along with associated objects, means that every changes made on your local repo will be updated also on the server, a sort of uploading data, a better practice i can suggest is to run both of commands at together ( git commit -am ‘Starting’ && git push origin master ), in this way will save time.
git pull origin master
Fetch from and merge with another repository or a local branch, means that you recevie the last modification from the server to your local repository ( local folder ).
Better to execute also this command with the commit commandbefore, in order to not lose any data, so to restore at the previews change.
git add
This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.
git add . -> will add every file of any type .
git status
Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by git (and are not ignored by gitignore(5)). The first are what you would commit by running git commit; the second and third are what you could commit by running git add before running git commit.
git reset
In the first and second form, copy entries from <commit> to the index. In the third form, set the current branch head (HEAD) to <commit>, optionally modifying index and working tree to match. The <commit> defaults to HEAD in all forms.

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.

Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols. Below are some rules need to follow for different protocols:
· ssh://[user@]host.xz[:port]/path/to/repo.git/
· git://host.xz[:port]/path/to/repo.git/
· http[s]://host.xz[:port]/path/to/repo.git/
· ftp[s]://host.xz[:port]/path/to/repo.git/
· rsync://host.xz/path/to/repo.git/

Leave a Reply

Your email address will not be published. Required fields are marked *