ππππ
ππππ
- 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! π"