How to Git clone on Ubuntu with GitLab and GitHub

I’m not one of those software developers that shuns a Windows-based GUI and portends that every operation performed on a computer is best performed using a command prompt or the BASH shell. But I will tell you that if you want to do version control with Git, the terminal window in Ubuntu is the best place to do it. Let me demonstrate that by showing you how to perform an Ubuntu Git clone operation, taking all of the content from both a GitHub and a GitLab repository and copying it all down to my local machine.

Steps to Git clone on Ubuntu

The following is the list of steps required to perform an Ubuntu Git clone:

  1. Open the Ubuntu terminal window.
  2. Ensure an Ubuntu Git installation exists.
  3. Issue the git clone command and specify the remote repo URL.
  4. Navigate into the directory created by the Ubuntu git clone.
  5. Perform basic Git commands such a push, branch, reflog and commit.

How to Ubuntu Git clone GitLab repos

The commands used in the Ubuntu Git clone example where the target was a GitLab project are as follows:

git-clone@ubuntu:~$ sudo apt install git
git-clone@ubuntu:~$ git --version
git-clone@ubuntu:~$ git clone https://gitlab.com/cameronmcnz/gitlab-made-easy.git
git-clone@ubuntu:~$ cd my-github-repo
git-clone@ubuntu:~$ git config --global user.email "[email protected]"
git-clone@ubuntu:~$ git config --global user.name "cameronmcnz"
git-clone@ubuntu:~$ touch my-file.html
git-clone@ubuntu:~$ git add .
git-clone@ubuntu:~$ git commit -m "good commit message"
git-clone@ubuntu:~git push origin master

GitHub Ubuntu Git clone example

The process of cloning a GitHub repo in Ubuntu isn’t that much different. Since the first set of commands installed Git and performed the one-off config operations, the set of commands is more compact:

git-clone@ubuntu:~$ git clone https://github.com/cameronmcnz/my-github-repo.git
git-clone@ubuntu:~$ cd my-github-repo
git-clone@ubuntu:~$ git config --global user.email "[email protected]"
git-clone@ubuntu:~$ git config --global user.name "cameronmcnz"
git-clone@ubuntu:~$ touch my-file.html
git-clone@ubuntu:~$ git add .
git-clone@ubuntu:~$ git commit -m "strong commit message"
git-clone@ubuntu:~$ git push origin master
git-clone@ubuntu:~$ git reflog

You can find these repositories on GitHub and GitLab.

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close