Setup Git on Ubuntu

Git is a popular distributed version control system utilized for tracking changes in source code during the development of software.

The Git software package is included within the Ubuntu 20.04 apt repositories. To install Git open the Terminal application by pressing ctrl+alt+t in Ubuntu and type the following commands.

sudo apt update

You will be prompted for your password.

sudo apt install git

Press the Y key if prompted.

Type the next command to view the version of Git.

git version

To setup your Git user details which are used as your identity by github.

git config --global  user.name "YourGitUsername"
git config --global  user.email "YourEmailAddress"

To verify config changes type this command.

 git config --list

Basic Git Commands

Some helpful Git commands from Phoenixnap.com

Find changed files in the working directory: git status

Change to tracked files: git diff

Add all changes to your next commit: git add

Add selected changes into your next commit: git add -p

Change the last commit: git commit -amend

Commit all local changes in tracked files: git commit -a

Commit previously staged changes: git commit

Rename a local branch: git branch -m new-name

List all currently configured remotes: git remote -v

View information about a remote: git remote show

Add a new remote repository: git remote add

Delete a remote repository: git remote remove [remote name]

Download all changes from a remote repository: git fetch

Download all changes from and merge into HEAD: git pull branch

Create a new branch with the command: git branch first-branch

To see more git commands use: git –help

Was this helpful?
0 reviews