Skip to content

Instantly share code, notes, and snippets.

View Qorbanzadeh's full-sized avatar
🏠
Working from home

Ali Qorbanzadeh

🏠
Working from home
View GitHub Profile

Aliases in git

Create aliases

git config --global alias.st "status"

Or add it manually in the config file, in the alias section:

git config --global -e

git bisect

To start the bisect operation, type:

git bisect start

Mark bad commits like this:

git bisect bad [commit]

Undo git commits

git reset

To undo local commits, you can use the git reset command:

git reset MODE COMMIT

Modes:

  • mixed => will reset the staging area to the commit we gave it! So it doesn't touch the changes we have in the working tree

git log

To see all the commits, from all the branches, type:

git log --all

To reverse the order of the log command, type:

git log --reverse

git commit

To save your staged changes to the git repository, type:

git commit -m "Message"

To use your default editor for the commit message, type:

git commit

Ignore file in git

.gitignore

There's three versions of gitignore file in git:

  • PROJECT_DIR/.gitignore or PROJECT_DIR/**/.gitignore
  • ~/.gitignore or SOMEWHERE_ON_YOUR_MACHINE/.gitignore
  • .git/info/exclude

Staging area

Please first make sure you're using git version [above 2.3][git-download]. You can also check out [my video][yt-install-git] about how to install and configure git

To check what version of git you're using, type:

git version

git status

@Qorbanzadeh
Qorbanzadeh / ssh-tutorial.md
Last active June 30, 2022 05:40
SSH Tutorial

Table of content

  • [What's SSH?][whats-ssh]
  • [How to use SSH?][use-ssh]
    • [SSH on Windows][ssh-on-windows]
    • [SSH on Mac][ssh-on-mac]
    • [SSH on server][ssh-on-server]
  • [Things to do after the first login on a server][after-first-login]
    • [Keep the server uptodate][update-server]
    • [Do not use the 'root' user][create-new-user]
  • [Disable root login][disable-root-login]

Git Repositories

To use git on your projects, you need to have a repository, we have two types of repositories:

  1. Bare repositoris
  2. Non-bare repositories

Bare repositories

Install and configure git

You can watch the video: How To Install And Configure GIT

Git commands start with git, followed by another command or some arguments:

git [command] [args]

For example: