Introduction Of Git

Introduction Of Git

Git is a simply version control system. which is used to maintain the version of our projects.

because if sometimes you add few changes in your existing project then git have already a previous version of this project.

All developers will use some kind of version control system, a tool to allow them to collaborate with other developers on a project without the danger of them overwriting each other's work, and roll back to previous versions of the code base if a problem is discovered later on. The most popular (at least among web developers) is Git, along with GitHub, a site that provides hosting for your repositories and several tools for working with them. This module aims to teach you what you need to know about both of them.

git2.png

  1. It is rare that you will work on a project completely on your own, and as soon as you start working with other people you start to run the risk of conflicting with each other's work — this is when both of you try to update the same piece of code at the same time. You need to have some kind of mechanism in place to manage the occurrences, and help avoid loss of work as a result.

  2. When working on a project on your own or with others, you'll want to be able to back up the code in a central place, so it is not lost if your computer breaks.

  3. You will also want to be able to roll back to earlier versions if a problem is later discovered. You might have started doing this in your own work by creating different versions of the same file.

javasrcipt_v1.js, javascript_v2.js, javascript_v3.js,.... etc.

Click here to know more

Note: There is a lot more that you can do with Git and GitHub, but we feel that the above represents the minimum you need to know to start using Git effectively. As you get deeper into Git, you'll start to realize that it is easy to go wrong when you start using more complicated commands. Don't worry, even professional web developers find Git confusing sometimes, and often solve problems by searching for solutions on the web, or consulting sites like Flight rules for Git and Dangit, git! git3.jpg

Example:

download a repository on GitHub to our machine Replace owner/repo with the owner and name of the repository to clone git clone github.com/owner/repo.git

change into the repo directory cd repo

create a new branch to store any new changes git branch my-branch

switch to that branch (line of development) git checkout my-branch

make changes, for example, edit file1.md and file2.md using the text editor

stage the changed files git add file1.md file2.md

take a snapshot of the staging area (anything that's been added) git commit -m "my snapshot"

push changes to github git push --set-upstream origin my-branch

Git Username

You can change the name that is associated with your Git commits using the git config command. The new name you set will be visible in any future commits you push to GitHub from the command line. If you'd like to keep your real name private, you can use any text as your Git username.

Changing the name associated with your Git commits using git config will only affect future commits and will not change the name used for past commits.