Skip to content

deepanshu-Raj/Version-Control-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version Control System

  • Author : Deepanshu Raj
  • Created On : Jan 4, 2021 (Monday)

Version Control System :

Git : Distributed Version Control System.

Features listed in this Repo :

  • Creating a Git repo.
  • Reviewing a Repo's History.
  • Adding Commits to a Repo.
  • Tagging, branching & Merging.
  • Undoing Changes.

Common Instructions:

✳ 1. Creating a Git Repo

  • git init : Create a new git Repository on your computer.
  • git clone : Copy an existing repo on your computer(from a remote repo).
  • git status : Status of the repo(at present).
  • git clone <project_name_that_you_want> : Copy Project with a different Project name.

✳ 2. Reviewing a Repo's History

  • git log : Log [SHA , Author , Date & Message] of all the commit made till present.
  • git log --oneline : Single-Line Log of all the commits till present.
  • git log --stat : More info[files modified,no. of insertions/deletions,Summary of total modified files/ lines added/removed] about the commits.
  • git log --patch : or git log -p : Show the exact changes(modifications) for each commit.
  • git log -p -w : Ignore whitespace Changes of the commits.
  • git show <first_7_chars_of_the_SHA> : Displays all the details of that particular commit, whose SHA has been given.
  • git diff : Display the Changes that have been made but haven't been commited yet.

✳ 3. Adding Commits to a Repo

  • git add : Stages the file.(WD->SI)
  • git add . : Stage all the modified files.
  • git rm --cached : Unstage a given File.(SI->WD)
  • git commit -m '' : Commit changes.(SI->repo) [Only message can be provided with such commits]
  • git commit : Commit changes.(SI->repo) [Default editor will open, & a desc. will be asked to enter].

{WD ~ Working Directory ; SI ~ Staging Index}

✳ 4. Tagging, Branching & Merging

  • git tag : Tells us about the already present tags.
  • git tag -a <tag_name> : To create an Annotated Tag.[with desc.] @ current commit.
  • git tag -d <tag_name> : To delete a particular tag.
  • git tag <tag_name> : To create a Lightweight Tag.[without desc.] @ current commit.
  • git tag -a <tag_name> <SHA_of_the_commit> : To tag a particular commit[commit with the specified SHA].
  • git branch : Display all the branches present at present in our repo.
  • git branch <branch_name> : Creates a new branch with <branch_name> as it's name.
  • git checkout <branch_name> : Changes the active branch to the branch with branch name as <branch_name>.
  • git checkout -b <branch_name> : Creates and checkout the branch with branch name as <branch_name>.
  • git branch -d <b_name> : deletes the branch with name as <b_name>.
  • git branch -D <b_name> : Force deletes the branch with name as <b_name>.
  • git branch <b_name> <SHA_of_the_commit> : Creates a branch at the commit whose SHA is passed.
  • git log --oneline --graph --all : Show all the branches in a visual representation.
  • git merge <name_of_the_branch_to_merge_in> : Merge the active branch with the branch provided.

✳ 5. Undoing Changes

  • git commit --amend : To modify the last commit(most recent commit)
  • git revert <SHA_of_the_commit> : To undo the changes done in the commit with the given SHA.
  • git reset <relative_reference> :
    • Modes(Labels) :
      • --mixed [git reset --mixed <relative_reference> or git reset <relative_reference> : move the changes from Repo to WD].
      • --soft [git reset --soft <relative_reference> : move the changes from repo to SI].
      • --hard [git reset --hard <relative_reference> : erase the commit]

{WD ~ Working Directory ; SI ~ Staging Index}

About

Basics of Git VCS CMD Line

Resources

Stars

Watchers

Forks