DEV Community

Mohd Talha
Mohd Talha

Posted on • Updated on

Version Control Basics

Hi everyone, Sharing some useful git commands to use,

$ git init
Turn an existing directory into a git repository
Enter fullscreen mode Exit fullscreen mode
$ git status
Tells what's going on
Enter fullscreen mode Exit fullscreen mode
$ git add <filename>
adds files to staging area
Enter fullscreen mode Exit fullscreen mode
$ git commit
Creates a new commit
- Write good commit messages!
Enter fullscreen mode Exit fullscreen mode
$ git clone [url]
Clone (download) a repository that already exists on Github
Enter fullscreen mode Exit fullscreen mode
$ git pull
Updates your current local working branch with all new commits from the remote branch
It is a combination of git fetch and git merge
Enter fullscreen mode Exit fullscreen mode
$ git log
Shows a flattened log of history
Enter fullscreen mode Exit fullscreen mode
$ git log - - all - - graph - - decorate
Visualize history as a DAG(Directed acyclic graph)
Enter fullscreen mode Exit fullscreen mode

What commands would you add?

Top comments (1)

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited
git commit --fixup <hash>

git commit --fixup :/<previous commit message>
git switch <branch>