Trying to do all the github commands to see the result
Git is a powerful version control system used for tracking changes in source code during software development. Here's a list of common Git commands along with explanations and examples:
- Description: Initializes a new Git repository.
- Example:
git init
- Description: Creates a copy of a remote repository on your local machine.
- Example:
git clone https://github.com/example/repo.git
- Description: Adds changes in the working directory to the staging area.
- Example:
git add file.txt
- Description: Records changes from the staging area to the repository.
- Example:
git commit -m "Commit message"
- Description: Shows the status of changes as untracked, modified, or staged.
- Example:
git status
- Description: Displays a log of commits.
- Example:
git log
- Description: Fetches changes from a remote repository and merges them into the current branch.
- Example:
git pull origin master
- Description: Uploads local changes to a remote repository.
- Example:
git push origin master
- Description: Lists, creates, or deletes branches.
- Example:
git branch git branch new-feature
- Description: Switches branches or restores working tree files.
- Example:
git checkout branch-name
- Description: Combines changes from different branches.
- Example:
git merge feature-branch
- Description: Manages remote repositories.
- Example:
git remote -v
- Description: Fetches changes from a remote repository but does not merge them.
- Example:
git fetch origin
- Description: Shows changes between commits, branches, etc.
- Example:
git diff
- Description: Resets the current HEAD to a specified state.
- Example:
git reset --hard HEAD~1
```bash
# Ensure you are on the labs branch
git checkout labs
# Fetch the latest changes from the remote repository
git fetch origin
# Reset the labs branch to match the master branch
git reset --hard origin/master
# Force-push the changes to the remote repository (be careful with force-push)
git push origin labs --force
```