How to Create a Local Git Repository Assignment

Assignment Task: How to Create a Local Git Repository

  1. Install Git on AWS Ubuntu.

  2. Create a directory with the name “My Project”.

  3. Initialize the “My Project” directory as an empty Git repository.

  4. Place your Eclipse project into this Git Repository.

  5. Create a .gitignore file and configure it to exclude these files (*.class, *.settings, *.project).

  6. Add the source code into the Staging Area.

  7. Commit the source code into the Local Git repository.

  8. Create a Remote repository on GitHub.

  9. Push the source code from the Local repository to the Remote Repository.

Additional Tasks:

  • Initialize any folder as a Git Repository.
  • Create file1.java and file2.java.
  • Add them to the staging area and commit.
  • Add file3.java and create a Stash for it.
  • Verify the stash list to ensure changes have been stored temporarily.
  • Apply the stash back to the branch.
  • Clear the Stash.
  • Add file3.java to the staging area and commit it to the repository.
  • Perform a soft reset to the 1st commit.
  • Revert the reset by doing a commit.
  • Perform a mixed reset to the 1st commit.
  • Revert the reset by adding the files to the staging area and committing.
  • Perform a hard reset.
  • Verify that changes have been removed from the system.

Your Task:

  1. Create a file Demo.java which prints “Hello World”.

  2. Create 2 branches out of this master: Feature1 and Feature2.

  3. Make changes in the Feature1 branch in the same line of code.

  4. Commit the code in the Feature1 branch.

  5. Now check out the Feature2 branch and make a change in the same line as you did in Feature1.

  6. Commit the code in the Feature2 branch.

  7. Merge the Feature2 branch into the Feature1 branch. It should give a merge conflict.

  8. Resolve the merge conflict with the help of Kdiff3 or Meld tool.

  9. Verify the merge using the git log command.

WhatsApp icon