The purpose of GIT is to manage a project or a set of files, as they change over time. Git store this information in a data structure called a Repository. A GIT repository contains among other things.
- A set of “ commit ” object
- A set of references to commit object, call heads.
‘Commit’ operation is used to apply changes from the working copy to the repository. This operation modifies the repository and other developers can see these changes by updating their working copy.
Before commit, one has to add files/directories to the pending change-list. This is the place where changes wait to be committed. With commit, we usually provide a log message to explain why someone made changes. This log message becomes a part of the history of the repository.
Commit is an atomic operation, which means either the entire commit succeeds or it is rolled back. Users never see half-finished commit.
Signing up for a new GitHub account
Let see the one example to signup for it.
You have to go on github domain by this link https://github.com/ and click the sign up option and fill the form by instruction like below
When you’re ready with your decision, click Sign up now.
- Type your username, email address, and password on the next screen.
- Select your plan type. If you’re unsure about what you need, you can just.
GitHub offers free accounts for users and organizations working on open source projects, as well as paid accounts for users and organizations that need private repositories.
Tip: You do not need a paid user account to access and work on repositories in an organization. Free accounts can work on an organization’s private repositories, as long as they are added as a team member.
Step 2: Signing up for service
Go to GitHub’s Plans & Pricing page by link https://github.com/pricing
Select the appropriate account type and level that you want to create. If you want more information about account types, you can read about the difference between a user and an organization account.
select the Free account type. You can upgrade or downgrade your account at any time, so don’t fret!
Click Finish sign up.
Congratulations, and welcome to GitHub! And something look like below
Before you start using Git, you have to make it available on your computer. Even if it’s already installed, it’s probably a good idea to update to the latestversion. You can either install it as a package or via another installer, or down-load the source code and compile it yourself. Go to the terminal
$ sudo apt-get install git
Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. You should have to do these things only once on any given computer; they’ll stick around between upgrades. You can also change them at any time by running through the commands again.
Git comes with a tool called git config. “git config” file in the Git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository.
If you ever need help while using Git, there are three ways to get the manual page (man page) help for any of the Git commands:
$ git help <verb>$ man git- <verb>
For example, you can get the man page help for the config command by running
$ git help config
These commands are nice because you can access them anywhere, even off – line If the man pages and this book aren’t enough and you need in-person help.
Getting a Git Repository
The repository is a central place where developers store all their work. Repository not only stores files, but also the history about changes. Which means it maintains a history of the changes made in the files.
See a example, how to create repository and follow the instruction
1- You have to log-in on github by the link https://github.com/ use of your e-mail id and password of github which is created before like
2- Go to your profile and click the option on repository and after that click the below option on new profile >Repository > New
now you can create the repository accordingly your requirement here many option are available and some we had discussed above. See the snapshot of it.
2– After creat Repository we got a link of our repository which access by http or SSH and got the instruction to create a new repository on the command line.
3- Go to your terminal and run these command , If you’re starting to track an existing project in Git, you need to go to the project’s directory and type or create a new project directory.
update# mkdir project_demo # echo "# linux_point">> README.md # git init # git add README.md # git commit -m "first commit" # git remote add origin email@example.com:gauravsrivastav/linux_point.git # git push -u origin master
Push an existing repository from the command line
# git remote add origin firstname.lastname@example.org:gauravsrivastav/linux_point.git # git push -u origin master
for preventing to type password all time when we do push so we can save our public-key on my Git hub- Account – followed by the instruction to run command.
# ssh-keygen -t rsa # cat ~/.ssh/id_rsa.pub # git push -u origin master # git log
Other “commands” that are useful at this point
git log shows a log of all commits starting from HEAD back to the initial commit. (It can do more than that, of course.)
git status shows which files have changed between the current project state and HEAD. Files are put in one of three categories: new files that haven’t been added (with git add), modified files that haven’t been added, and files that have been added.
git diff shows the diff between HEAD and the current project state. With the –cached option it compares added files against HEAD; otherwise it compares files not yet added.
git mv and git rm mark files to be moved (rename) and removed, respectively, much like git add.
# git status to see what files I changed. # git diff [file] to see exactly what I modified. # git commit -m [message] to commit.
And if you want to any commit change then revert it for this have to follow the instruction and run the command from terminal. git log it will show your committed log the first will be latest commit <alphanumerical> copy it and run with below like
# git revert <commit> # git log now you can see you commit will be change
You should have a basic understanding of what Git is and how it’s different from the centralized version control system you may have previously been using.