Setup:
git config --global user.email "email"
- It sets your Git user email address. This email will be associated with your commits and will be visible to others collaborating on the project.
git config --global user.name "firstname lastname"
- It
sets your Git user name. This will also be displayed with your commits.
1. Initialization:
git init
- git init: It creates a hidden
.gitfolder.
git clone [url]
- git clone: It retrieves an existing Git repository from a remote hosting service (like GitHub) and creates a local copy on your machine
2. Staging Your Work
git add [file]
- git add: It indicate specific files you want to include in the next commit.
git diff
- git diff: It display the differences between working directory and the staging area.
3. Committing Changes
git commit -m "[message]"
- git commit: It captures the current state of your staged files.
The [message] provides a brief description of the changes made.
4. Inspect
git status
- git status: It provides a quick overview of the current state of your working directory.
- It shows unstaged changes, staged changes, and untracked files
git log
- git log: It displays a log of all your commits, including the commit message, and date.
5. Share & Update
git remote add [alias] [url]
git remote add: To add a remote repository.[alias]: This is a user-defined alias or nickname you assign to the remote repository for easier identification.
(e.g., “origin”, “upstream”, “work”).[url]: This is the URL of the remote repository you want to connect to
git push [alias] [branch_name]
git push : To push your local commits to the remote repository’s specified branch (master or main).
git pull
- git pull: Fetch the changes from the remote repository and merge them into the local branch.
6. Branch
git branch [branch-name]
- git branch branch-name: creates a new branch, allowing to work on a separate feature
git branch
- git branch: list all branches
git checkout [branch-name]
- git checkout: switch to different branch in local repository
git merge [branch_name]
- git merge: the changes from another branch (master or main) into your current branch.

Leave a comment