🌟🌟🌟🌟
🌟🌟🌟🌟
- Overview
- Introduction to Version Control Using Git
- Setting up Git
- Git Cheat Sheet
- Uploading Files to GitHub with Branching
- Why This Git Training?
- License
- Star This Repository
- Conclusion
Welcome to Git Training, a Hands-On Training repository led by Shreya Malogi! 🌟 comprehensive guide to getting started with Git. This training edition covers not only the basic GitHub workflow but also provides an introduction to version control using Git, essential command-line interface commands, and a Git cheat sheet. 📘🚀
Version control allows you to manage a 🔄 collection of files, such as 💻 source code for a project or 📁 files for a website, by 🕰️ keeping track of changes over time. It eliminates the ✨ need to archive entire directories to 🤝 maintain different versions manually. Git, a distributed version 🌐 control system, is widely used for efficient collaboration and code management.
- Learn basic command-line interface commands:
mkdir
,cd
,ls
,rm
,mv
💻
- Installing Git
- Learn basic Git commands:
log
,status
,diff
,stash
,commit
,add
,rm
,.gitignore
,branch
,checkout
🚀- Cloning, pulling, push 🔄
- Learn basic GitHub actions:
- Pull requests, forking 🌐
Download & Install Git from git-scm.com. ⬇️
After installing Git, introduce yourself to Git with your name and public email address:
git config --global user.email "yourmail@example.com"
git config --global user.name "Your User Name Comes Here"
To check your credentials:
git config user.name
git config user.email
Make sure you run these commands in your working folder/project folder. 📂
Command | Description |
---|---|
git init |
Initialize a new Git repository 🔄 |
git clone <url> |
Clone a repository into a new directory 📂 |
git remote add origin <url> |
Add a remote repository 🌐 |
git remote -v |
Display remote repositories 📊 |
git status |
Show the working tree status 🌳 |
git add . |
Add changes to the index ➕ |
git commit -m "Commit Message" |
Commit changes with a message 📝 |
git commit -am "Commit Message" |
Add and commit changes in one command 📦 |
git push origin master |
Push commits to a remote repository 🚀 |
git fetch |
Download objects and refs from a remote repository 📥 |
git pull |
Fetch from and integrate with another repository or a local branch 🔄 |
git branch |
List, create, or delete branches 🌿 |
git checkout <branch> |
Switch branches or restore working tree files 🔄 |
git merge <branch> |
Join two or more development histories together 🤝 |
git log |
Show the commit logs 📜 |
git diff |
Show changes between commits, commit and working tree, etc. |
git stash |
Stash changes in a dirty working directory away 📥 |
git rm <file> |
Remove files from the working tree and from the index ❌ |
Here's the complete set of commands to upload files to GitHub using Git, including creating a new branch:
-
Initialize a Git Repository:
git init
-
Add Files to the Staging Area:
git add . # Add all files
or
git add <file1> <file2> # Add specific files
-
Commit Changes:
git commit -m "Your commit message here"
-
Create a New Branch:
git branch <branch-name>
This command creates a new branch but doesn't switch to it.
-
Switch to the New Branch:
git checkout <branch-name>
or, using the more recent
git switch
command:git switch <branch-name>
Alternatively, you can combine branch creation and switching in one command:
git checkout -b <branch-name>
-
Make Changes, Add, and Commit in the New Branch:
git add . git commit -m "Your commit message here"
-
Add a Remote Repository (GitHub):
git remote add origin https://github.com/your-username/your-repository.git
-
Push the Changes to GitHub:
git push -u origin <branch-name>
The
-u
option sets the upstream branch for the new branch.
Now, you've initialized a Git repository, added files, committed changes, created a new branch, made changes in the new branch, and pushed the changes to GitHub. Remember to replace your-username
, your-repository
, and <branch-name>
with your actual GitHub username, repository name, and the desired branch name.
Happy coding and branching! 🚀🌿
Whether you're a Git novice or eager to enhance your skills, this hands-on experience, ensures effective learning.
Open-source under the MIT License.
MIT License
Copyright (c) 2020 CodeMacrocosm
Show support if you find it helpful!
Congratulations! You've completed this extended tutorial and have a solid foundation in using Git for version control. Use the provided Git cheat sheet as a quick reference, and explore more about the power of pull requests in the GitHub Flow Guide. 🌟
Happy coding! 🚀🎉✨👩💻🌟🏁
Begin your Git journey today. Happy Learning! 🌟"