Basic commands: add, commit, diff, reset

Suppose we changed the file storage.py in the working tree.

git status tells us that storage.py was modified.

On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   storage.py

git diff displays the differences between the working tree and the INDEX:

diff --git a/src/sardana/macroserver/recorders/storage.py b/src/sardana/macroserver/recorders/storage.py
index ffb5a1e..56ba021 100644
--- a/src/sardana/macroserver/recorders/storage.py
+++ b/src/sardana/macroserver/recorders/storage.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-
+# 1. change 
 ##############################################################################
 ##
 ## This file is part of Sardana

git diff --cached compares the INDEX and the last commit and it shows no differences.

git diff origin/develop develop comparing the remote repo and the develop branch of the local repo does not show differences either.

git diff origin/develop comparing the remote repo and the working tree detects differences:

diff --git a/src/sardana/macroserver/recorders/storage.py b/src/sardana/macroserver/recorders/storage.py
index ffb5a1e..56ba021 100644
--- a/src/sardana/macroserver/recorders/storage.py
+++ b/src/sardana/macroserver/recorders/storage.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-
+# 1. change 
 ##############################################################################
 ##
 ## This file is part of Sardana

Then we add the modifications of storage.py to the INDEX and make the same comparisons:

$ git add storage.py
$ git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   storage.py

$ git diff
$ git diff --cached
diff --git a/src/sardana/macroserver/recorders/storage.py b/src/sardana/macroserver/recorders/storage.py
index ffb5a1e..56ba021 100644
--- a/src/sardana/macroserver/recorders/storage.py
+++ b/src/sardana/macroserver/recorders/storage.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-
+# 1. change 
 ##############################################################################
 ##
 ## This file is part of Sardana

git diff sees no differences because the working tree and the INDEX are in-sync.

git diff --cached displays the differences between the INDEX and the local repo.

Now we do a git commit to sync the local repo and the INDEX:

$ git commit
[develop bff3cf2] just a test
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git status
On branch develop
Your branch is ahead of 'origin/develop' by 1 commit.
  (use "git push" to publish your local commits)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

The differences:

$ git diff
$ git diff --cached
$ git diff origin/develop develop
diff --git a/src/sardana/macroserver/recorders/storage.py b/src/sardana/macroserver/recorders/storage.py
index ffb5a1e..56ba021 100644
--- a/src/sardana/macroserver/recorders/storage.py
+++ b/src/sardana/macroserver/recorders/storage.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-
+# 1. change 
 ##############################################################################
 ##
 ## This file is part of Sardana

The difference are now between the remote and the local repo.

Finally we want to cleanup. git reset --hard origin/develop resets the local repo, the INDEX and the working tree.

$ git reset --hard origin/develop