GIT & GIT Repository- How it Works


images (1)
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.

  1.  A set of “ commit ” object  
  2.  A set of references to commit object, call heads.

Commit Changes

‘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.

GIT ACCOUNT

Signing up for a new GitHub account

Let see the one example to signup for it.

Step1: Signup

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.

Selection_006 

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

Selection_007

Installing GIT

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.

Getting Help

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

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

username: prince.g.k12@gamil.com (prince.g.k12, would be your email’s user name )

password: *******

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.

Selection_008

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.

HTTPS|SSH: git@github.com:gauravsrivastav/linux_point.git

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.

$  sudo  apt-get   update
# mkdir   project_demo
# echo   "# linux_point">> README.md
# git   init
# git   add README.md
# git commit   -m "first commit"
# git remote  add  origin git@github.com:gauravsrivastav/linux_point.git
# git push  -u   origin master

Push an existing repository from the command line

# git remote add origin git@github.com: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.

Advertisements

7 thoughts on “GIT & GIT Repository- How it Works

  1. Gaurav Srivastava says:

    It is one of my favorite posts, because when I was new for GIT Repository, on that time i had reviewed various article and post and Lecture’s videos ! That was awesome experience.
    After sometime, I thought lets do a documentation from “basic to how to install and configure and ‘git command’ tools” for new / freshers to learn and execute them from here ! Hope it will be helpful !
    Thank you !!!!

    Liked by 1 person

  2. Jim says:

    I’ll immediatey grasp your rsss feesd ass I cann nott too fknd your emajl subscription hyperlinkk or nwsletter service.

    Do you’ve any? Kinly permit mme recognizee in oder thaat I
    mayy subscribe. Thanks. I have ben surfibg onlije more han 4 hohrs today, yett
    I nnever found anyy interesting atticle like yours.
    It’s prtty wokrth enugh forr me. In myy view, iif alll ste oweners andd
    bliggers made ood cpntent ass yyou did, the internet
    wikl bbe a lott mpre usefuul than ever before. It’s perfedt tine
    to make soome pkans ffor thee futurfe andd it’s ttime to be happy.

    I’ve redad this post and iif I coould I wiish tto suuggest yoou ffew intrresting
    tjings orr advice. Perhapls youu caan wite nexst articles
    refedrring tto tbis article. I ant too read evesn more
    things about it! http://Cspan.co.uk

    Liked by 1 person

    • Gaurav Srivastava says:

      giv me your email id I will add you in my subscribe list or when you refresh the page from new browser then you will be able t see in right bottom’s corner end to follow this blog… please enter your email and go to your mailbox and confirm it…
      thanks,

      Like

  3. Kaylee says:

    In all truth evidence is continuing to mount showing everything is normal and working according to design except for some Darwin dropouts that started a self prrvaesetion cult to get around Charles theory.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s