Basic Git commands

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

gi…


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

  1. git init: Initializes a new Git repository.
  2. git clone: Clones an existing repository from a remote location.
  3. git add <file>: Stages a file for the next commit.
  4. git add .: Stages all changes in the current directory.
  5. git commit -m "<message>": Commits changes with a meaningful message.
  6. git log: Displays a log of all commits made.
  7. git status: Shows the status of changes in the repository.
  8. git branch <branch-name>: Creates a new branch.
  9. git checkout <branch-name>: Switches to a different branch.
  10. git merge <branch-name>: Merges changes from another branch.

Intermediate Git Commands

  1. git remote add <name> <url>: Adds a remote repository.
  2. git fetch: Fetches changes from a remote repository.
  3. git pull: Fetches and merges changes from a remote repository.
  4. git push: Pushes local changes to a remote repository.
  5. git diff: Displays differences between commits or files.
  6. git stash: Temporarily saves changes to be reapplied later.
  7. git reset <commit>: Resets the repository to a specific commit.
  8. git tag <tag-name>: Creates a tag for a specific commit.

Advanced Git Commands

  1. git rebase: Reapplies commits on top of another branch.
  2. git cherry-pick <commit>: Applies a specific commit to the current branch.
  3. git submodule: Manages subprojects within a repository.
  4. gitk --all: Visualizes the commit history.
  5. 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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Basic Git commands." John Akpakwu | Sciencx - Sunday July 28, 2024, https://www.scien.cx/2024/07/28/basic-git-commands/
HARVARD
John Akpakwu | Sciencx Sunday July 28, 2024 » Basic Git commands., viewed ,<https://www.scien.cx/2024/07/28/basic-git-commands/>
VANCOUVER
John Akpakwu | Sciencx - » Basic Git commands. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/28/basic-git-commands/
CHICAGO
" » Basic Git commands." John Akpakwu | Sciencx - Accessed . https://www.scien.cx/2024/07/28/basic-git-commands/
IEEE
" » Basic Git commands." John Akpakwu | Sciencx [Online]. Available: https://www.scien.cx/2024/07/28/basic-git-commands/. [Accessed: ]
rf:citation
» Basic Git commands | John Akpakwu | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.