Git Basics


                                               Git
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Download Git
  • At the beginning learning git is really a pain to everyone,sometimes it's hard to understand it's flow.
  • But don't worry in this post I've summarized git flow to easy steps that you can follow easily.
  • To follow these steps create a directory anywhere in your file system
  • Create a html file name it as index.html
  • Now open the terminal/cmd or git bash in your working directory.
  • Follow these steps
<!DOCTYPE html>
<html>
<head>
<title>RkDevblog</title>
</head>
<body>
<h1>Line 1</h1>
</body>
</html>
1.Initialize a git repository/your project
git init
2. To Check untrack files
git status
3. Add to stagging area to keep track of files (here filename is index.html)
git add filename
4. Now let's change one line in index.html,change line 7 to Line 2
Now to view the changes or to view the differences you made
git diff index.html
Screenshot (168)
Now add the changed file in to stagging area by
git add index.html
5.Now we've made a change, we need to commit our changes to our local repository
git commit -m "Initial commit
6.You have done all these changes to your local repository, What if you want push changes to remote repository(Github)
7.View current remotes by
git remote -v
8.You will see no output,Because their is no remote repository yet created.Let's create a New GitHub repository
Git Repo
Here my repository name is Test copy the HTTPS url ends with .git here(https://github.com/Rajithkonara/Test.git) and add  remote repository from the terminal
git remote add origin <your repository url>
9.Now check the remotes again,you will see the origin url's.
10.Finally
git push origin master
Now you have successfully pushed your code to remote repository.
These are the very basic step's of git their are many things left to learn like branching,merging,resolving conflicts etc.I'll leave these for you to learn.

Recommended Learning Sources

Thank you for Reading:)