git logo

Basic Git Commands

EBAVS/ Try to work hard with latest technologies. We work with git for several years and we learned a lot.

This is a simple reference guide with commands that we use in day to day from the beginning of a project.

Initialising Repo with Git

First of all, we create a project (actually we download skeletons from a composer, but this is another history or post):

Then we initialise git repository. This is important because git makes their local repository for local working:

Working with Repository

When you initialized we can begin work, then create a simple file for testing:

then add simple code:

now add this file to a repository:

or

Now we have a repository with some of the code. It’s time to move this code, we have code added but isn’t in the repo yet. Write:

The files are committed to a repo, are stored in this and assigned a short guide identifier 6f30a7f for us.

Go to change index.php and see what happens in next commit:

And change to:

Look what we add -a parameter. This means that we change a file. If we only add files don’t need -a parameter.

We have our application ready to store on the remote server. We could make a remote in github or in bitbucket. I Have a preference for bitbucket because I can make private repos for free. But github is good too.

When we make a repository, in github for example, they make a new URL for the repository, the URL construction is:

https://github.com/user/repo.git

A user is your username and Repo are the repository name.  For this example a real URL could be:

https://github.com/ebavs/example.git

Then is time to add this remote repository to our local repository:

We have connected now our local repo with our remote repo, time to move code to remote:

And we have our repo working.

Summary

commands that we used:

 

Update:

If you like it you can visit our next post talking about Git:

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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