This is a quick reference guide for beginners to Git version control. It provides step-by-step instructions on common Git commands and workflows, from initializing a repository to collaborating with others and managing project history. Whether you're new to Git or need a refresher, this guide aims to help you navigate through the essential concepts and commands efficiently
-
Create a New Repository: Initialize a new Git repository for your project.
git init -
Add Files to the Repository: Add your project files to the repository.
git add <file(s)> -
Commit Changes with a Message: Record the changes to the repository.
git commit -m "Initial commit" -
Connect to a Remote Repository: Link your local repository to a remote repository on GitHub (replace
<repository-url>with your GitHub repository URL).git remote add origin <repository-url> -
Push Changes to GitHub: Upload your local commits to the remote repository on GitHub.
git push -u origin master
-
Add Changes to the Staging Area: Prepare changes for commit.
git add <file(s)> -
Commit Changes with a Message: Record changes to the repository.
git commit -m "Commit message"
-
Push Changes to a Remote Repository: Upload local commits to a remote repository.
git push -
Pull Changes from a Remote Repository: Fetch and merge changes from a remote repository.
git pull -
Create a New Branch: Start working on a new feature or bug fix.
git branch <branch-name> -
Switch to a Branch: Navigate between different branches.
git checkout <branch-name> -
Merge Changes from Another Branch: Combine changes from one branch into another.
git merge <branch-name>
-
Check Repository Status: View the status of tracked and untracked files.
git status -
View Commit History: See a log of commits.
git log -
List Remote Repositories: Display configured remote repositories.
git remote -v -
Fetch Objects and References from Another Repository: Download objects and refs from another repository.
git fetch -
List, Create, or Delete Tags: Manage tags for marking important points in history.
git tag
With these basic Git commands, you can efficiently manage your version-controlled projects and collaborate with others. Feel free to explore more advanced Git features as you become more comfortable with the basics.
Dizzpy | Happy coding! 🖥️🥰