Notes

GIT

Git is a distributed version control system that tracks versions of files. It’s shell (git bash) is built as a linux based command line tool.


Mechanism

text


Commands

git status
git init
git add .
git add --a
git add <filename>
git -h
git rm --cached <filename>
git commit -m "message"
git log
rm -rf .git
pwd   --> present working directory
ls    --> list
cd    --> change directory
touch --> to create a file in the repo
.gitignore is a file in which the file names included in it get ignored by git. It ignores blank
folders by default.
*.txt # ignores all files with this extension/name
/folder # ignores all folderes and subfolders of this name
git clone <link>
# between working directory and staged area
git diff 

# between staged area and commit
git diff --staged
git commit -a -m "message"
git stash       # Hold changes

git stash apply # Re-apply the changes
git mv <filename> <newname>
git checkout -- <filename>

# For restoring all files
git checkout -f

# For restoring from staged area
git restore --staged -- <filename>

Remote

It is the remote repository where your files are stored with git. (Like github or gitlab)

# view remote repo name
git remote

# Add the remote repo link to local
git remote add <name> <url>

# View push and pull commands
git remote -v

# Push changes
git push -u <remote_name> <branch>

# Pull changes
git pull

Config

Branch

Reverting

Cheat Sheet

A CheatSheet published by Digital Ocean on a HacktoberFest Event.

Find it Here