Skip to content

docs: Add cleaned-up Git merge vs rebase guide with commit graphs#9

Closed
CodeCrafterX7 wants to merge 3 commits intoSomeshdiwan:masterfrom
CodeCrafterX7:master
Closed

docs: Add cleaned-up Git merge vs rebase guide with commit graphs#9
CodeCrafterX7 wants to merge 3 commits intoSomeshdiwan:masterfrom
CodeCrafterX7:master

Conversation

@CodeCrafterX7
Copy link
Copy Markdown

📝 PR Title:

docs: Add cleaned-up Git merge vs rebase guide with commit graphs

📄 Description:

### Summary

This PR introduces a cleaned-up, well-formatted markdown document explaining the difference between `git merge` and `git rebase`, complete with commit graph diagrams and workflow examples.

The guide is designed to help contributors understand the impact of each method on commit history, improving pull request hygiene and Git fluency across the team.

---

### Changes Made

- Cleaned inconsistent bullet styles (mixed tabbed and plain bullets)
- Removed visual clutter such as ⸻ separators
- Removed prompt-style text at the end ("Want me to also sketch...")
- Preserved ASCII diagrams and technical explanations

---

### File Location Suggestion

The document can be added to:

docs/git-merge-vs-rebase.md

@Someshdiwan Someshdiwan self-assigned this Oct 1, 2025
@Someshdiwan Someshdiwan added the documentation Improvements or additions to documentation label Oct 1, 2025
Copy link
Copy Markdown
Author

@CodeCrafterX7 CodeCrafterX7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok working on it

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).

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+).
@Someshdiwan Someshdiwan self-requested a review October 1, 2025 01:51
@CodeCrafterX7 CodeCrafterX7 closed this by deleting the head repository Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants