0% found this document useful (0 votes)
3 views3 pages

Git Collaboration for Java Login Feature

The document outlines the steps taken to implement login functionality in a Java application using Git for version control. Key actions included cloning the repository, creating a feature branch, editing the 'login.java' file, committing changes, pushing to GitHub, creating a pull request, and merging the changes into the main branch. Additionally, it describes handling a merge conflict that arose during the process.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Git Collaboration for Java Login Feature

The document outlines the steps taken to implement login functionality in a Java application using Git for version control. Key actions included cloning the repository, creating a feature branch, editing the 'login.java' file, committing changes, pushing to GitHub, creating a pull request, and merging the changes into the main branch. Additionally, it describes handling a merge conflict that arose during the process.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Assignment: Git Operations in Team Collaboration (Java Project)

Scenario
You are part of a team developing a basic Java-based application. The team is using GitHub
for collaboration and version control. You are assigned to create a feature branch,
implement login functionality, and merge the changes into the main branch.

Steps Performed

1. Clone the Repository


The repository was cloned to the local system using:

git clone <repository_url>

This command downloads the project from GitHub to the local machine.

2. Create a Feature Branch


A new branch was created from the main branch to add the login functionality:

git checkout -b feature/add-login-functionality

Outcome: A new branch 'feature/add-login-functionality' was created and checked out.

3. Make Changes to [Link]


The file '[Link]' was edited to include basic login functionality (username and password
fields).

Before Changes (Initial Content):

public class Login {


public static void main(String[] args) {
[Link]("Login functionality to be added.");
}
}

After Changes (Added Functionality):

import [Link];

public class Login {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter Username: ");
String username = [Link]();

[Link]("Enter Password: ");


String password = [Link]();

if ([Link]("admin") &&
[Link]("password")) {
[Link]("Login Successful!");
} else {
[Link]("Invalid Credentials.");
}

[Link]();
}
}

4. Stage and Commit Changes


The modified file was staged and committed with a descriptive message:

git add [Link]


git commit -m "Added login functionality with username and
password fields"

Outcome: Changes saved in local Git history.

5. Push the Changes to Remote


The committed changes were pushed to the remote feature branch:

git push origin feature/add-login-functionality

Outcome: The branch was successfully pushed to GitHub.

6. Create a Pull Request (PR)


On GitHub, a Pull Request was created from 'feature/add-login-functionality' into the 'main'
branch.

PR Description Example:
Implemented basic login functionality with username and password fields in [Link].
Added input handling and basic validation.

7. Merge the Pull Request


Once the PR was approved by the team, it was merged into the 'main' branch via the GitHub
interface.
After merging, the latest changes were pulled locally:

git checkout main


git pull origin main

8. (Optional) Handling Merge Conflict


To simulate a conflict, a different change was made to '[Link]' in both 'main' and 'feature'
branches. On merging, Git highlighted a conflict.

Conflict Example in [Link]:

<<<<<<< HEAD
[Link]("Welcome to the application!");
=======
[Link]("Login Successful!");
>>>>>>> feature/add-login-functionality

Resolution: The conflict was resolved manually by editing the file and then committing:

git add [Link]


git commit -m "Resolved merge conflict in [Link]"

Final Outcome
1. Branch 'feature/add-login-functionality' created and used.

2. [Link] updated with login functionality.

3. Changes committed with descriptive message.

4. Feature branch pushed to GitHub.

5. Pull Request created and merged into main.

6. (Optional) Merge conflict successfully resolved.

Conclusion
This assignment demonstrates end-to-end usage of Git in a collaborative environment,
covering cloning, branching, committing, pushing, pull requests, merging, and resolving
conflicts.

You might also like