This content originally appeared on DEV Community and was authored by John Akpakwu
Introduction
Git is a powerful version control system used to track changes in source code, documents, and other digital content. Understanding Git commands is essential for effective collaboration and management of projects.
Basic Git Commands
-
git init
: Initializes a new Git repository. -
git clone
: Clones an existing repository from a remote location. -
git add <file>
: Stages a file for the next commit. -
git add .
: Stages all changes in the current directory. -
git commit -m "<message>"
: Commits changes with a meaningful message. -
git log
: Displays a log of all commits made. -
git status
: Shows the status of changes in the repository. -
git branch <branch-name>
: Creates a new branch. -
git checkout <branch-name>
: Switches to a different branch. -
git merge <branch-name>
: Merges changes from another branch.
Intermediate Git Commands
-
git remote add <name> <url>
: Adds a remote repository. -
git fetch
: Fetches changes from a remote repository. -
git pull
: Fetches and merges changes from a remote repository. -
git push
: Pushes local changes to a remote repository. -
git diff
: Displays differences between commits or files. -
git stash
: Temporarily saves changes to be reapplied later. -
git reset <commit>
: Resets the repository to a specific commit. -
git tag <tag-name>
: Creates a tag for a specific commit.
Advanced Git Commands
-
git rebase
: Reapplies commits on top of another branch. -
git cherry-pick <commit>
: Applies a specific commit to the current branch. -
git submodule
: Manages subprojects within a repository. -
gitk --all
: Visualizes the commit history. -
git clean
: Removes untracked files and directories.
Conclusion
Mastering Git commands is essential for effective version control and collaboration. This article covers basic, intermediate, and advanced Git commands to help you manage your projects efficiently.
This content originally appeared on DEV Community and was authored by John Akpakwu
John Akpakwu | Sciencx (2024-07-28T22:28:48+00:00) Basic Git commands. Retrieved from https://www.scien.cx/2024/07/28/basic-git-commands/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.