Welcome to our Git tutorials! In this comprehensive guide, we'll walk you through the basics of Git, a powerful tool for version control. By the end, you'll be able to manage your code like a pro. 💡
Git is a free and open-source distributed version control system. It's used to track changes in computer files and coordinating work on those files among multiple people. Essentially, it helps keep your code organized, and makes collaboration easier.
Before we dive into Git commands, let's install it on your machine.
brew install git.sudo apt-get install git.Now that Git is installed, let's set up your user information.
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Every Git project is a repository, and every repository has a working directory and a .git directory. To create a new repository, navigate to your project directory and run:
git initgit add 📝Adds files to the staging area, preparing them to be committed.
git add . # Adds all files
git add file.txt # Adds a specific filegit commit 📝Saves the changes in the staging area to the local repository.
git commit -m "Commit message"git status 📝Shows the current status of your repository.
git statusgit pull 📝Updates your local repository with changes from the remote repository.
git pull origin mastergit push 📝Sends your local commits to the remote repository.
git push origin masterWhat does `git add` do?
Branches allow you to work on different parts of a project independently. To create a new branch, use:
git branch new-branch
git checkout new-branchTo merge branches, use:
git checkout master
git merge new-branchA .gitignore file lists the files that Git should ignore. This helps keep unnecessary files out of your repository.
For more advanced Git topics like merging conflicts, rebasing, and tags, check out our advanced Git tutorial.
We hope you enjoyed learning Git with us! If you have any questions or feedback, don't hesitate to contact us. Happy coding! 💡