New Tutorials:   KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL  
See the Tutorial List

GIT: Cloning

Unless you are starting the project yourself, the first step to start working on a Git based process is cloning the repository you will be working with. Git provides some simple commands to help us get started.

Normally, remote repositories are repositories that are on computers which are accessible to you via the network. To Git, remote just means somewhere else. But since you may not have another computer handy, we shall work with repositories that are on the same computer but have different paths. Let's go ahead and clone our current repository awesome_project. Git has a command for that and yes, you guessed it right, its $git clone. Of course you need to specify what you need to clone.

If you are working on a different computer, this will probably be a network address. If the repository is hosted on some server, this will be a URL. Right now, we can provide it a path to our awesome_project repository. Let's name our clone our_clone_project.

Cloning in GIT

Take a look inside that repository and you can see everything is there as you'd expect. Git has automatically set up our awesome repository as a remote repository for us. Run $ git remote and you shall see that it prints out origin which is our original repository. Let's switch back to our original repository and run $ git remote again.

Nothing is printed out. As you can see our original repository is in no way affected by the clone. This is good, since if someone decided to take a look at your code, you don't want your repository to change.

But the problem here is that we want our two repositories to communicate to each other and our awesome_project has no idea that our_clone_project exists. Let's fix that by using the $ git remote add command. You need to provide a name for this add, and using origin does not make sense here. Let's call it our_clone and provide the path to our repository. Poof! That's done!

Cloning in GIT

We can now create new branches, files and work together. But how do we keep up to date with changes in both the repositories. In the next chapter, we'll talk about pushing and pulling our changes between repositories.