1. How do you create a new repository in GitHub?
Repositories are used to store and manage project files and version history.
Go to GitHub → Click on “New” → Enter repository name → Choose visibility (Public/Private) → Click “Create repository”
2. How do you clone a repository to your local machine?
Cloning a repository copies its contents to your local system for development.
git clone https://github.com/username/repository.git
3. How do you create a new branch in Git?
Branches allow you to work on features or fixes independently from the main codebase.
git branch feature-branch
git checkout feature-branch
4. How do you merge a branch into the main branch?
Merging integrates changes from one branch into another.
git checkout main
git merge feature-branch
5. How do you resolve merge conflicts in Git?
Merge conflicts occur when changes in two branches overlap. They must be resolved manually.
Edit conflicting files → Mark resolved sections → git add file → git commit
6. How do you push changes to a remote repository?
Pushing updates the remote repository with your local changes.
git push origin branch-name
7. How do you pull the latest changes from a remote repository?
Pulling fetches and integrates changes from the remote repository into your local branch.
git pull origin branch-name
8. How do you create a pull request in GitHub?
Pull requests propose changes from one branch to another and allow for code review.
Go to GitHub → Navigate to your repository → Click “Pull Requests” → Click “New Pull Request” → Select branches → Submit
9. How do you revert a commit in Git?
Reverting creates a new commit that undoes the changes of a previous commit.
git revert commit-hash
10. How do you squash commits in Git?
Squashing combines multiple commits into one to keep the commit history clean.
git rebase -i HEAD~n (where n is the number of commits to squash)
11. How do you set up SSH keys for GitHub?
SSH keys allow secure authentication with GitHub without entering a password.
ssh-keygen -t rsa -b 4096 -C “your_email@example.com”
Copy the public key → Add it to GitHub under Settings → SSH and GPG keys
12. How do you use GitHub Actions for CI/CD?
GitHub Actions automate workflows like building, testing, and deploying code.
Create a .github/workflows directory → Add a YAML file (e.g., main.yml) → Define jobs and steps
13. How do you fork a repository in GitHub?
Forking creates a copy of a repository under your account for independent development.
Go to the repository → Click “Fork” → Choose your account
14. How do you contribute to an open-source project on GitHub?
Contributing involves forking the repository, making changes, and submitting a pull request.
Fork the repository → Clone it locally → Create a branch → Make changes → Push changes → Submit a pull request
15. How do you tag a specific commit in Git?
Tags mark specific commits, often used for versioning releases.
git tag -a v1.0 -m “Version 1.0”
git push origin v1.0
Search
Categories
Recent Posts
Top Git interview Questions for Experienced Developer
Speed-up tips and tricks for Windows 11
Top 15 Linux Commands used by Experienced Developer
Top SQL Interview Examples for Experienced Developer
Internal Working of Java HashMap
Recent Tags