Jim Lynch Codes
  • Blog
  • About Jim

Writings about one coder's stories & experiences.

Seeing File Changes in Command Line At Various Points Of The Git Commit Lifecycle

12/1/2016

0 Comments

 
I personal like the control you have when using git from the command line, and a nice thing to be able to do is see the changes I've made (duh hehe). I really didn't know the proper name for this so I am calling it the "git commit lifecycle", but basically these are shell scripts you can run to see your changes before you add the changes, after you add them but before committing, and after committing. Enjoy!

View Your Current Files Changed

You can aways see what files you have changed since committing by running:
git status

View Changes Before The Files Were Added

You can see the changes you've made to all files by running:
git diff
This will display a list of all your changes which you can scroll through with the down arrow key. 
Picture
The "diff" keyword tips you off that that particular line is the beginning of a diff block (a snippet or snippets from a code file that tells you about changes is that file). Then it tells you was file it's talking about. The "+++" means that this version of the file has things added to it, and the "---" doesn't have them. Then (in the yellow color above) is the actual code from my file. the lines in green with a plus on the left are my changes! This tells you that the way in which this file changed was that these two lines were added. If code was removed then these will show in a similar fashion but with red color and minus signs to the left on the line.

View Changes After The Files Were Added But Before Committed

To view the changes in a similar form to "git diff" but this time showing changes that have been made to files that were added but not yet committed, you can run this:
git diff --cached

View Changes After Files Were Added But Before Committed

To view these same changes after you commit the files but before you push them you can run this command:
git diff HEAD^ HEAD 

Anything Else?

This was a relatively short post that was meant to be, "just the facts, ma'am", Let me know if there's anything I'm missing or anything you think should be added here! :)
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    ​Author

    Picture
    The posts on this site are written and maintained by Jim Lynch. About Jim...
    Picture
    Follow @JimLynchCodes
    Follow @JimLynchCodes

    Categories

    All
    Actionscript 3
    Angular
    AngularJS
    Automated Testing
    AWS Lambda
    Behavior Driven Development
    Blockchain
    Blogging
    Business Building
    C#
    C / C++
    ClojureScript / Clojure
    Coding
    Community Service
    CS Philosophy
    Css / Scss
    Dev Ops
    Firebase
    Fitness
    Flash
    Front End
    Functional Programming
    Git
    Go Lang
    Haskell
    Illustrations
    Investing
    Java
    Javascript
    Lean
    Life
    Linux
    Logic Pro
    Music
    Node.js
    Planning
    Productivity
    Professionalism
    Python
    React
    Redux / Ngrx
    Refactoring
    Reusable Components
    Rust
    Security
    Serverless
    Shell Scripting
    Swift
    Test Driven Development
    Things
    TypeScript
    Useful Sites
    Useful Tools
    Video
    Website Development
    WebStorm
    Writing

    Archives

    March 2023
    August 2021
    February 2021
    January 2021
    October 2020
    September 2020
    May 2020
    April 2020
    February 2020
    January 2020
    December 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    August 2017
    July 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015

    RSS Feed

  • Blog
  • About Jim
JimLynchCodes © 2023