arrow_back
Back

01. Git

Andrew Dorokhov Andrew Dorokhov schedule 2 min read
menu_book Table of Contents

Setting up a client

Global settings:

git config --global user.name "Andrew Dorokhov"
git config --global user.email "andrew@dorokhov.dev"

Local settings:

git config --local user.name "Andrew Dorokhov"
git config --local user.email "andrew@dorokhov.dev"

Check current values:

git config -l

Global configuration will be saved in ~/.gitconfig file.

Local configuration will be saved in .git/config file.

Creating a repository

git init

Check status

git status
git status -s

What changes will be commited:

git diff --staged

Adding to stage area

Adding to stage area (or to index):

git add filename

Commits

git commit -m "Description of the commit."

History

git log
git log -n # show last n commits
git log -p # show difference in code
git log --pretty=oneline # show one commit per one line

Branches

Show all the branches:

git branch

Create a branch:

git branch branch-name

Create and checkout a branch using one command:

git checkout -b branch-name

Switch to another branch:

git checkout branch-name

Delete a branch:

git branch -d branch-name

Delete a remote branch:

git push -d origin branch-name

Merging

git merge branch-name

Recovery

If we want to recovery some tracked file to its first-beginning state, we should enter:

git checkout -- filename

Tags

Create a tag for the current commit:

git tag 1.0.1

Push a single tag to remote repository:

git push origin tag-name

Push all the tags:

git push --tags

.gitignore

Create a .gitignore file and add any files to it:

vendor
runtime
*.log

Platforms for Git

Tools

code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Creating a logo

arrow_forward