Git

The commands and tips using in git.

Main documentations on website https://git-scm.com/docs

Install Git on Linux

Quick start

Clone, add, commit and push (GitHub)

$ cd projects #your path
$ pwd
# 1. Clone project from GitHub
$ git clone https://github.com/testerBartek/GIT
$ cd GIT
$ git status
# 2. Create test.txt with wrote Test Git
$ echo "Test Git" >> test.txt
$ ls
$ cat test.txt
$ git status
# 3. Add, Commit with message
$ git add test.txt
$ git status
$ git commit -m "Add a test.txt file"
$ git status
# 4. Push to remote Repo (GitHub)
$ git push origin master

Init (Fresh Project), use alias notepad++, remove

Unzip and mv of dir, remote GitHub

The basic commands

Setup and Config

git

git config

Getting and Creating Projects

git init

git clone

Basic Snapshotting

Basic Git Workflow

git add

With dot "." adding all the untracked files.

git status

On start of learning use this command very often.

git restore

git reset

git commit

git rm

git mv

Remember to use git mv not only mv. If we don't use it files wouldn't be renamed. They are deleted and add new one. After that use git add -A to repair it.

Branching and Merging

git log

To quit command $ git logs use key "q"

Using alias helps to save our time

Patching

git revert

Sharing and Updating Projects

git pull

Check for modifications and copy it from remote Repository.

git push

git remote

Add existing local repository to GitHub remote repository.

Guides

gitignore

something in .gitignore file will never be commited

Plumbing Commands

git ls-files

Git programs integrations

Environment variable

  1. Copy path of file .exe of your program

  2. Open Advanced system settings

  3. Advanced

  4. Environment Variables

  5. Find Path in system variables and Click Edit...

  6. Add new path like (C:\Program Files\Notepad++)

Adding alias

Alias to git bash

  1. Path to Your user like $ pwd /c/Users/nn

  2. Use command $ notepad++ .bash_profile

3. In new line just type an alias like You want. For example to open "notepad++" don't type whole name just type or "npp".

4. Save and close notepad++. Close and open again git bash. 5. Now after type $ npp should open notepad++

Alias to .git projects

  1. alias to git log --all --graph --decorate --oneline"

Notepad++

Generally remember to close notepad++ and back to git bash.

  1. Add notepad++ to environment variable

  2. After that notepad++ could be run from git bash

3. You could add alias to create shortcut to open notepad++ like in Adding alias Heading.

4. Add notepad++ to global core editor

5. Check is it correct (if open in notepad++ it is correctly)

Last updated

Was this helpful?