This is my first GitHub repository.
Author - SumitSahu444
git init
Initialize a new Git repository in your current directory.
git clone <repository_URL>
Clone a repository from a remote source (e.g., GitHub).
-
git add <file>
Stage a specific file for the next commit. -
git rm <file>
Remove a file and stage its deletion. -
git commit -m "<message>"
Commit staged changes with a descriptive message. -
git commit -am "<message>"
Stage and commit all modified tracked files in one step (skipgit add
).
-
git status
Displays the status of your working directory and staging area. -
git log
Shows a history of commits, including commit hashes, authors, and messages.
-
git checkout <branch>
Switch to a specific branch. If the branch doesn’t exist, create and switch withgit checkout -b <new_branch>
. -
git branch
List all branches and highlight the current branch.
-
git pull
Fetch changes from a remote repository and merge them into your local branch. -
git push origin <branch>
Push commits from your local branch to the corresponding remote branch.
-
git merge <branch>
Merge changes from a specified branch into the current branch. -
git stash
Temporarily save your uncommitted changes to a stack, allowing you to work on something else and restore them later withgit stash apply
.
-
git fetch
Fetch updates from a remote repository without merging them. -
git revert <commit_hash>
Revert a specific commit by creating a new commit that undoes its changes. -
git reset <commit_hash>
Move the current branch pointer to a specified commit. Use--soft
to keep changes staged or--hard
to discard them.
git diff
Display changes between your working directory and the last commit, or between specific commits or branches.
git tag <tag_name>
Create a tag for marking specific commits. Use-a
to create annotated tags with messages.
git remote -v
Show the list of remote repositories and their URLs.
git rm --cached <file>
Remove a file from the staging area without deleting it from the working directory.
Happy coding!