Git basics

Table of content

Git is an essential tool for version control and collaboration in software development. This guide covers the fundamental Git commands that every beginner should know. From configuring your user information to managing branches and viewing logs, you'll learn the basics to get started with Git effectively.

Current Config

1git config --list

Configure user and email

1git config --global user.name "Your Name"
2git config --global user.email "email@email.com"

Clone a repo

1git clone https://github.com/Benoit-Gaumard/ProjectName

Get the current branch

1git status

Add a folder

1git add .

Create a commit (Local)

1git commit -m "feat: bga first commit"

Push modifications to the remote branch

1git push

Get the last version of the repo from the remote branch

1git pull

Change branch

1git checkout mybranch

List local branches

1git branch

List remote branches

1git branch -r

List local and remote branches

1git branch -a

Delete a branch (Local)

1git branch -d my-branch-name
2git branch -D my-branch-name

Configure repo

1git config –global user.name "Your Name"
2git config –global user.email you@example.com

Display repo config

1git config --global --list

Logs

1git log -v
2git log -p

Create a branch (local)

1git branch my-new-branch
2git checkout -b feat-azure-functions

Delete branch (Local)

1git branch -d my-branch

Delete branch (Remote)

1git push origin -d my-branch

List modified files

1git diff -r --no-commit-id --name-only

Misc

1gitk --all