Version Control System
It is for tracking changes in the files. Three types of Version Control Systems
· Local Version Control Systems
· Centralized Version Control Systems
· Distributed Version Control Systems
The local version control system
The local version control system maintains track of files within the local system.
Centralized Version Control Systems
Centralized version control systems contain just one repository and each user gets their own working copy
Distributed Version Control Systems
Distributed version control systems contain multiple repositories. Each user has their own repository and working copy.
git init
initialize Local git repo
git add <file>
add files to index
git status
to get the status of the working tree
git commit
to commit changes
git push
to push a commit to the remote repository
git pull
to pull the latest code from the working repo
git clone
to clone the repo to a new directory
To delete the branch in remote
$ git push -d <origin_name> <branch_name>
Example
$ git push -d origin <branch_name
Local
To create new branch
git branch branch-name
To Restore Deleted branch
git branch <branch-name> <restore-commit-id>
Switching branch
$ git switch <existing_branch>
$ git switch -c <non_existing_branch>
Commit
To delete last commit message (not changes)
git reset HEAD~
To discard all changes
git reset — hard.
To stash changes
git stash save <text>
git stash -u
->Will stash including untracked files
git stash list
git stash apply ‘<stash-id-from-list>’
To delete stash
git stash pop
→ Will apply and delete the newest one
git stash drop <stash-id-from-list>
Repository hosting services
Repository hosting services are third-party web applications that wrap and enhance a version control system. You cannot fully utilize a repository hosting service without using an underlying version control system.