π‘ git init
Creates a new local Git repository in your project directory. It sets up all the internal .git files needed to start tracking versions of your code.
π‘ git add
Adds specified file(s) to the staging area, telling Git you want to include them in the next commit. Example: git add filename.txt or git add . to stage everything.
π‘ git commit
Takes the staged files and permanently records their current state in the repository's history. You must provide a message:
Example: git commit -m "Add new feature"
π‘ git status
Displays the state of your working directory and staging area β shows which files are modified, staged, or untracked.
π‘ git log
Shows a list of all the commits made in the repository along with their hash IDs, authors, and commit messages.
π‘ git branch
Shows all local branches in your repo. The * indicates the current branch. You can also use it to create a new branch:
Example: git branch feature-1
π‘ git branch -M main
Renames your current branch (often master) to main. The -M flag forces the rename if the target name already exists.
π‘ git config --global user.name
Sets your name and email address globally so Git can attribute commits to you.
π‘ git config --global user.email
Sets your name and email address globally so Git can attribute commits to you.
π‘ git push
Sends your commits to a remote repository (like GitHub). Use -u for the first push to link your local branch with the remote one:user.email
Sets your name and email address globally so Git can attribute commits to you.
Top comments (0)