This README provides a quick reference for essential Git commands used in day-to-day development.
git initInitializes a new Git repository in the current directory.
git clone <repository-url>Creates a local copy of a remote repository.
git statusShows the status of your working directory and staging area.
git add <file-name>
# or
git add .Stages changes for commit.
git commit -m "Your commit message"Saves staged changes with a message.
git logDisplays the commit history of the repository.
git branch <branch-name>
git checkout <branch-name>
# or
git switch <branch-name>Creates and moves to a new branch.
git pullFetches and merges changes from the remote repository.
git push origin <branch-name>Uploads your commits to the remote repository.
git checkout <target-branch>
git merge <source-branch>Merges changes from one branch into another.
git checkout -- <file-name>
# or
git reset --hardReverts changes in your working directory.
git rm <file-name>Removes a file from the working directory and stages the deletion.
git remote add origin <repository-url>Links your local repo to a remote GitHub repository.
- Create a GitHub repo.
- Initialize Git (if not already):
git init
- Add and commit the README:
git add README.md git commit -m "Add basic Git commands README" - Add remote:
git remote add origin <your-repo-url>
- Push to GitHub:
git push -u origin main
Your README is now uploaded to GitHub!