DEV Community

Cover image for Git - Staging and Snapshoting
Sasidharan
Sasidharan

Posted on • Originally published at lagandlog.com on

Git - Staging and Snapshoting

Staging and snapshotting are important topics because these commands will be used by us daily.

Installation and setup were covered in the previous log.

  1. Local Setup

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows. Let's have look at only commands that required to stage and commit to your working branch.

Working with Git stage and commit

git status
Enter fullscreen mode Exit fullscreen mode
  • show modified files in the working directory.
 git add [file] (or) git add . 
Enter fullscreen mode Exit fullscreen mode
  • you can add the file one by one to the stage or use ( . ) to add all your files at once to the stage.
 git reset [file] (or) git reset . 
Enter fullscreen mode Exit fullscreen mode
  • unstage a file while retaining the changes in the working directory or reset all files using ( . ) at the end.
 git diff
Enter fullscreen mode Exit fullscreen mode
  • check the changes made compared with the previous commit for the unstaged files.
git diff --staged
Enter fullscreen mode Exit fullscreen mode
  • check the changes made in stages files before commit.

Commit your code

 git commit -m "[descriptive message]" 
Enter fullscreen mode Exit fullscreen mode
  • this command commits your staged files with changes to the repository, you should give a descriptive message about the commit.

Happy Coding 👾

AMA on Twitter

Top comments (0)