Git is a version control system. For example, if you have a file on which you’ve been working on and reworking for a long time, all the versions of it are saved in Git, and you can easily get back to every version.
What is Version Control System ?
We as a programmer can't track every files in our project so we use a version control system which tracks documents, files and everything in our projects and keep tracks of changes made into version control system.
What is it for?
The version control system has the following benefits:
• You have access to all versions of all files in the Git repository at any time, it’s almost impossible to lose any part of a code.
• Multiple developers can work on one project at the same time without interfering with each other, and without fear of losing any changes made by a colleague. In Git, the possibilities of collaborative work are unlimited.
Differences between Github workflow vs Local Git Workflow
Github Work Flow
- Write Code
- Commit
- Pull Request
Git WorkFlow
- Write Code
- Add Changes
- Commit Changes
- Push it to repo
- Make pull requests
Basic keywords you should know before getting started
repo
—> repositoryclone
—> bring a repo down from the internet (remote repository like Github) to your local machineadd
—> track your files and changes with Gitcommit
—> save your changes into Gitpush
—> push your changes to your remote repo on Github (or another website)pull
—> pull changes down from the remote repo to your local machinecli
—> Command Linecd
→ ChangeDirectory
1. Configuring Your Name & Email
In your terminal, run the following commands to identify yourself with Git:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Replace the values inside the quotes with your name and email address.
1) The git config
command
Here’s the git config
command:
git config user.name
which in my case returns:
Kaarthik
Configuring Email
git config user.email
And you can change your Git email address like this:
git config --global user.email [your email address here]
Let's get our hands dirty by learning Git Commands
1. Git Init
git init
Command helps us to initialize a repository on our local machine ie: Computer or laptop
2. Git Status
The git status
Command shows all the files that are committed , updated, and deleted in a project.
U - Untracked Files
M - Modified Files
3. Git Add
Now we have to track all the files and we can do that by using the command git add file1 file2
or by using the command git add .
which just tracks every file in our project.
4. Git Commit
After tracking the files we need to commit the files ie: saving the files. We must use the command git commit -m "Message"
and the message have to do something with what and why they commit you're making.
For Example: If you have added index.html to your project then your message must be git commit -m "Added Index.html"
5. Git Push
Now that we have committed everything we have to now push the code from our local machine to the remote repository in GitHub. Before that, we have to set the location of the remote repository since we are working on local machine git remote add origin [https://github.com/Vig-T/DemoApp.git](https://github.com/Vig-T/DemoApp.git)
where the origin → location of remote repo followed by repo link and remote → refers to a remote repository on GitHub
Next, we have to push it to remote repository by using the command git push -u origin master
Refresh the Repository Page
After using the above command we have to refresh the page and we will end up seeing this page.
Summary
As a developer, it is important to know git commands and one should have a Github profile. Be sure to sign up on GitHub or Bitbucket. These services offer great manuals on how to start working with remote repositories.GitHub is way ahead of bitbucket, and has turned into the standard and Mecca of the whole open source community. These are some of the basic commands which you can almost see every single and Let's learn about git branching in then next blog <3
Thanks for reading my blog & Let's connect! 🙌🏼
Follow me for more similar articles :D
Feel free to subscribe to my Youtube Channel & Follow me on Twitter <3