git clone and git fork?
git clone is used to create a local copy of an existing remote repository. It downloads the repository and its entire history to your local machine. git fork is a feature provided by platforms like GitHub, which creates a personal copy of someone else's repository in your GitHub account. This forked repository can then be cloned to your local machine using git clone.main or master. Developers can create new branches, switch between branches, and merge branches when changes are ready to be integrated.git merge and git rebase?
git merge and git rebase are used to integrate changes from one branch into another:
git merge combines the changes from one branch into another by creating a merge commit. It preserves the history of both branches.git rebase moves or combines a sequence of commits to a new base commit. It rewrites the commit history to create a linear progression of commits, which can make the project history cleaner and easier to understand.What is a Git commit and how do you create one?
Answer: A Git commit is a snapshot of the changes in the project files. It represents a point in the project’s history and includes a message describing the changes. To create a commit, you use the following commands:
bashCopy code
git add <file> # Stage the changes
git commit -m "Commit message" # Create the commit with a message
How do you undo the last commit in Git?
git reset or git revert command:
git reset --soft HEAD~1: Moves the HEAD pointer to the previous commit, keeping the changes in the staging area.git reset --hard HEAD~1: Moves the HEAD pointer to the previous commit and discards the changes.git revert HEAD: Creates a new commit that undoes the changes made in the last commit, preserving the commit history.What is the difference between git pull and git fetch?
git fetch downloads the latest changes from the remote repository but does not merge them into your local branch. You need to merge the changes manually.git pull is a combination of git fetch and git merge. It fetches the changes and automatically merges them into your current branch.How do you resolve merge conflicts in Git?
git status.git add.git commit.What is a Git stash and how do you use it?
git stashgit stash applygit stash listgit stash popgit stash drop stash@{n}