Problem Statements : Git & Github Session β St. Josephβs GDG Meeting
17 December 2024 at 15:13
List of problem statements enough to get your hands dirty on git. These are the list of commands that you mostly use in your development.
Problem 1
- Initialize a Repository.
- Setup user details globally.
- Setup project specific user details.
- Check Configuration β List the configurations.
Problem 2
- Add Specific files. Create two files app.js and style.css. User git add to stage only style.css . This allows selective addition of files to the staging area before committing.
- Stage all files except one.
Problem 3
- Commit with a message
- Amend a commit
- Commit without staging
Problem 4
- Create a Branch
- Create a new branch named feature/api to work on a feature independently without affecting the main branch.
- Delete a branch.
- Force delete a branch.
- Rename a branch.
- List all branches.
Problem 5
- Switch to a branch
- Switch to the main branch using git checkout.
- Create and switch to a branch
- Create a new branch named bugfix/001 and switch to it in a single command with git checkout -b.
Problem 6
- Start with a repository containing a file named project.txt
- Create two branches (feature-1 and feature-2) from the main branch.
- Make changes to project.txt in both branches.
- Attempt to merge feature-1 and feature-2 into the main branch.
- Resolve any merge conflicts and complete the merge process.
Problem 7
- View history in one-line format
- Graphical commit history
- Filter commits by Author
- Show changes in a commit
Problem 8
- Fetch updates from remote
- Fetch and Merge
- Fetch changes from the remote branch origin/main and merge them into your local main
- List remote references
Problem 9
- Create a stash
- Apply a stash
- Pop a stash
- View stash
Problem 10
- You need to undo the last commit but want to keep the changes staged for a new commit. What will you do ?
Problem 11
- You realize you staged some files for commit but want to unstage them while keeping the changes in your working directory. Which git command will allow you to unstage the files without losing any change ?
Problem 12
- You decide to completely discard all local changes and reset the repository to the state of the last commit. What git command should you run to discard all changes and reset your working directory ?