News Stay informed about the latest enterprise technology news and product updates.

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:

[email protected]:~$ sudo apt install git
[email protected]:~$ git --version
[email protected]:~$ git clone https://gitlab.com/cameronmcnz/gitlab-made-easy.git
[email protected]:~$ cd my-github-repo
[email protected]:~$ git config --global user.email "[email protected]"
[email protected]:~$ git config --global user.name "cameronmcnz"
[email protected]:~$ touch my-file.html
[email protected]:~$ git add .
g[email protected]:~$ git commit -m "good commit message"
[email protected]:~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:

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

You can find these repositories on GitHub and GitLab.

SearchAppArchitecture
SearchSoftwareQuality
SearchCloudComputing
SearchSecurity
SearchAWS
Close