Wanna learn Git but hate tutorials? Here are the only commands you need to know!
Git is an important tool for project management because it provides a way to manage and track changes to code and other project files over time. With Git, developers can work independently on the same project without interfering with each other’s changes. It also allows for collaboration among team members, as changes can be easily merged together.
Here’s a list of important Git commands along with a brief description of each:
git init
- Initializes a new Git repository. This command creates a new .git directory within the project folder, which tracks changes to the project files.$ cd path/to/your/project $ git init
git clone
- Clones an existing Git repository from a remote source (e.g., a GitHub repository) to your local machine.$ git clone https://github.com/WRITE_USERNAME HERE /repo.git
git add
- Adds one or more files to the staging area, preparing them to be committed.$ git add path/to/file
git commit
- Commits changes to the Git repository, which creates a new version of the project. Commits should always have a descriptive message.$ git commit -m "Add a descriptive message here"
git status
- Shows the status of the repository, including any changes that have been made but not yet staged or committed.$ git status
git log
- Shows the history of all commits made to the repository.$ git log
git diff
- Shows the differences between two versions of a file.$ git diff path/to/file
git branch
- Manages branches in a Git repository. Branches allow multiple users to work on different aspects of a project simultaneously.$ git branch branch_name
git checkout
- Switches between different branches in a Git repository.$ git checkout branch_name
git merge
- Merges changes from one branch into another.$ git merge branch_name
git push
- Pushes changes from a local repository to a remote repository (e.g., GitHub)$ git push origin branch_name
git pull
- Pulls changes from a remote repository to a local repository.$ git pull
git stash
- Temporarily saves changes that have not been committed, allowing you to switch to a different branch.$ git stash
git reset
- Resets the repository to a previous state. This command can be used to undo commits or discard changes that have not yet been committed.$ git reset --hard HEAD
git rm
- Deletes a file from the repository and stages the deletion$ git rm path/to/file
Conclusion:
These are the most commonly used Git commands and will be enough to give you a headstart on your learning. There are much more available depending on your specific needs.
Happy Learning!
Feel free to message me on my Social accounts for any help: