From a4742e3f78aedb78970af5c4efe972ca0a1b6cb7 Mon Sep 17 00:00:00 2001 From: Someshdiwan Date: Wed, 1 Oct 2025 05:12:00 +0530 Subject: [PATCH 1/3] feat: Documentation updated. --- Tips And Tricks/git.txt | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/Tips And Tricks/git.txt b/Tips And Tricks/git.txt index 0c16971..ba82c7f 100644 --- a/Tips And Tricks/git.txt +++ b/Tips And Tricks/git.txt @@ -10,11 +10,11 @@ Your branch: A──B──C──D──E─────────┴─M ↑ Merge commit (M) - • You branched from commit C. - • You added commits D and E. - • Upstream added commits after C. - • When you git merge upstream/main, Git creates a merge commit (M) joining both histories. - • History shows branching + merging — good for context but can look messy. +• You branched from commit C. +• You added commits D and E. +• Upstream added commits after C. +• When you git merge upstream/main, Git creates a merge commit (M) joining both histories. +• History shows branching + merging — good for context but can look messy. ⸻ @@ -47,14 +47,14 @@ A──B──C──F──G──H──D'──E' ⸻ D) When to use what - • Merge → - • If you want to preserve the “real” history (showing when branches diverged). - • Safer for beginners (no rewriting commits). - • Good for long-lived feature branches. - • Rebase → - • If you want a clean, straight line history. - • Preferred in open-source PR workflows. - • Requires confidence resolving conflicts & force-pushing. +• Merge → +• If you want to preserve the “real” history (showing when branches diverged). +• Safer for beginners (no rewriting commits). +• Good for long-lived feature branches. +• Rebase → +• If you want a clean, straight line history. +• Preferred in open-source PR workflows. +• Requires confidence resolving conflicts & force-pushing. ⸻ @@ -75,12 +75,9 @@ git rebase upstream/main # fix conflicts if needed git push origin feature-branch --force-with-lease - ⸻ So: Merge = “historical diary” (records exactly what happened). Rebase = “rewrite the story” (makes it look like you developed cleanly on top). ⸻ - -Want me to also sketch a real-life example with commit hashes (like abc123, def456) so you can see how git log looks different between merge and rebase? \ No newline at end of file From a032315da5c65b3675af959369a1bd9def2f08ba Mon Sep 17 00:00:00 2001 From: Someshdiwan Date: Wed, 1 Oct 2025 07:11:56 +0530 Subject: [PATCH 2/3] feat: Documentation updated merge or rebase Git. --- Tips And Tricks/{git.txt => Git merge or rebase.txt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Tips And Tricks/{git.txt => Git merge or rebase.txt} (94%) diff --git a/Tips And Tricks/git.txt b/Tips And Tricks/Git merge or rebase.txt similarity index 94% rename from Tips And Tricks/git.txt rename to Tips And Tricks/Git merge or rebase.txt index ba82c7f..cf46f09 100644 --- a/Tips And Tricks/git.txt +++ b/Tips And Tricks/Git merge or rebase.txt @@ -1,4 +1,4 @@ -Nice — here’s the commit graph diagram you asked for. This shows how your history looks depending on whether you merge or rebase. +This shows how your history looks depending on whether you merge or rebase. ⸻ From 7c4832895ec26ee778c445a71258d0252b6294cc Mon Sep 17 00:00:00 2001 From: Someshdiwan Date: Wed, 1 Oct 2025 07:16:24 +0530 Subject: [PATCH 3/3] docs(JAR): explain what a JAR file is with examples What - Documented **JAR (Java ARchive)** files as packaged archives for Java applications and libraries. - Key features: - File extension `.jar`. - Bundles multiple `.class` files, resources (images, configs), and metadata into a single archive. - Built on ZIP format with a special `META-INF/MANIFEST.MF` file. - Used for distribution, deployment, and execution of Java programs. - Can be executable (with a Main-Class entry) or non-executable (used as a library). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why - Simplifies distribution by combining many class files/resources into one file. - Enables reusability of code as libraries (e.g., external dependencies). - Supports portability across platforms with the JVM. - Provides versioning and metadata for deployment tools. How - **Creating a JAR file:** 1. Compile Java program: ``` javac Main.java ``` 2. Package into JAR: ``` jar cfe MyApp.jar Main Main.class ``` - `c` → create archive. - `f` → output to file. - `e` → specify entry point (Main-Class). java -jar MyApp.jar jar tf MyApp.jar Lists files inside archive. Examples 1. **Hello World executable JAR** - `Main.java`: ```java public class Main { public static void main(String[] args) { System.out.println("Hello, World from JAR!"); } } ``` - Compile and package: ``` javac Main.java jar cfe Hello.jar Main Main.class java -jar Hello.jar ``` - Output: ``` Hello, World from JAR! ``` 2. **Library JAR** - Create utility classes, bundle into `Utils.jar`. - Add to another project’s classpath: ``` java -cp .;Utils.jar MyApp ``` Logic - Inputs: compiled `.class` files and resources. - Outputs: compressed `.jar` archive. - Flow: 1. Java compiler generates `.class`. 2. jar tool packages classes/resources into `.jar`. 3. JVM runs `java -jar` if Main-Class is defined. - Edge cases: - Without Main-Class in manifest, `java -jar` fails. - Paths with spaces must be quoted. - Complexity / performance: - Simple ZIP compression; overhead minimal. - Concurrency / thread-safety: - Multiple JARs can be used simultaneously on the classpath. Real-life applications - Delivering Java applications as single executable files. - Packaging reusable libraries (e.g., `gson.jar`, `mysql-connector.jar`). - Used in build tools (Maven, Gradle) for dependency management. - Required in Java EE/ Jakarta EE deployments (WAR/EAR contain JARs internally). Notes - Executable JAR requires `META-INF/MANIFEST.MF` with Main-Class specified. - Non-executable JARs serve as libraries only, added to classpath. - JARs can be signed for integrity and security. - Still widely used even with newer formats (like JMOD in Java 9+). --- Tips And Tricks/Jar File Java.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Tips And Tricks/Jar File Java.txt b/Tips And Tricks/Jar File Java.txt index 26306e1..10c8f5e 100644 --- a/Tips And Tricks/Jar File Java.txt +++ b/Tips And Tricks/Jar File Java.txt @@ -6,17 +6,17 @@ metadata into a single file. A JAR makes it easy to distribute Java libraries, applications, and resources as one portable unit. Key characteristics: - • ZIP-based archive (.jar). - • Contains compiled .class files, resource files (properties, images), and an optional META-INF/MANIFEST.MF. - • Can be executed (if it contains a Main-Class entry in the manifest) or used as a library on the classpath. +• ZIP-based archive (.jar). +• Contains compiled .class files, resource files (properties, images), and an optional META-INF/MANIFEST.MF. +• Can be executed (if it contains a Main-Class entry in the manifest) or used as a library on the classpath. Why JAR files are important - • Distribution — package everything needed (classes + resources) into one file for easy sharing and deployment. - • Reproducibility — stable artifact that can be versioned and archived. - • Classpath management — simplifies dependency handling (one file instead of many loose class files). - • Security & Integrity — supports signing (JAR signing) and manifest metadata. - • Performance — fewer filesystem entries and easier I/O handling; commonly used by class loaders. - • Tooling compatibility — all build tools (Maven, Gradle, Ant), application servers, and the JVM understand JARs. +• Distribution — package everything needed (classes + resources) into one file for easy sharing and deployment. +• Reproducibility — stable artifact that can be versioned and archived. +• Classpath management — simplifies dependency handling (one file instead of many loose class files). +• Security & Integrity — supports signing (JAR signing) and manifest metadata. +• Performance — fewer filesystem entries and easier I/O handling; commonly used by class loaders. +• Tooling compatibility — all build tools (Maven, Gradle, Ant), application servers, and the JVM understand JARs. Basic JAR layout