Working with Git on the command line (Linux)

Working with Git on the command line (Linux)

Git basics

Simple instruction how to handle git on the command line

Check if Git is installed and ready

If not, you can install git using (on Ubuntu)

Set username and email

Every commit is marked with username and email to identify the autor

You can check the informations using

(1) Initialize a local directory for Git

If you want to include your local directory to version control, use init to tell Git what to track

.git directory is created including configuration files

(2) Clone a repo

If you want to start working on some existing project, you can clone it (copy) to your local machine. You can use HTTPS or SSH. Using HTTPS you have to put credentials every time, using SSH only first time.
HTTPS:

SSH:

Switching branches

Where master is the branch name

Download the latest changes in the project

Where remote is usually origin and branch is your target branch (master or something else).

View remote repos

Add a remote repo

Where name is your defined source name.

Create a branch

Switch to branch

View changes

View differences

Add and commit local changes

Note: Folders with no files inside are not added to Git

Add all changes to commit

. means all in Git

Push changes

Where remote is usually origin and branch is your target branch (master or something else).

Delete all local changes

Undo most recent commit

But better is to create another commit 🙂

Merge branches

Merge branch-name to master

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments