Working with git locally.
git status On branch master ❶ No commits yet ❷ Untracked files: ❸ (use "git add <file>..." to include in what will be committed) Math.java nothing added to commit but untracked files present (use "git add" to track) ❹
Our project currently has got only one branch. See |
|
Committing resources is an active task. We have not yet performed any commit. |
|
We have added a file |
|
Friendly hint how to proceed. |
public class Math { static public int add( final int a, final int b) { return a + b; } } |
public class Math {
/**
* Summing two int values.
* @param a first value.
* @param b second value.
* @return The sum of both.
*/
static public int add(
final int a, final int b) {
return a + b;
}
} |
> javac Print.java Math.java # Compilation creating Math.class and Print.class
> git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
Math.class
Print.class
nothing added to commit but untracked files present (use "git add" to track)
-
Math.class
andPrint.class
are being generated fromMath.java
andPrint.java
. -
Rule of thumb: Do not version dependent objects.
Solution: Add a .gitignore
file to
versioning to contain:
# ignore generated .class files
*.class
git log commit 0137ccd857a242f4751e36bdbce365c6130c3a32 ❶(HEAD -> master) Author: Martin Goik <goik@hdm-stuttgart.de> Date: Sat May 25 11:56:00 2019 +0200 Removing duplicate headline ❷ commit 7f119fac36e02e4c5a7f04f022217b6f744d6e1d ❸ Author: Martin Goik <goik@hdm-stuttgart.de> Date: Sat May 25 11:49:52 2019 +0200 Project Readme.md ❹ ...
Latest commit among with its hash value. |
|
Latest commit message. |
|
Previous commit among with its hash value. |
|
Previous commit message. |
git checkout 7f119fac36e02e4c5a7f04f022217b6f744d6e1d Note: checking out '7f119fac36e02e4c5a7f04f022217b6f744d6e1d'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at 7f119fa Project Readme.md
No. 126
git local, DIY
Q: |
Repeat the current example using your own workspace. |