Why GIT differnece than another SCM?

rajeshkumar created the topic: Why GIT differnece than another SCM?
Why GIT differnece than another SCM?
Cheap Local Branching
Everything is Local
Git is Fast
Git is Small
The Staging Area
Distributed
Any Workflow
Easy to Learn
Git is the new standard
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

What does commit object contain and What is SHA1?

rajeshkumar created the topic: What does commit object contain and What is SHA1?
The SHA
All the information needed to represent the history of a project is stored in files referenced by a 40-digit “object name” that looks something like this:

6ff87c4664981e4397625791c8ea3bbb5f2279a3

You will see these 40-character strings all over the place in Git. In each case the name is calculated by taking the SHA1 hash of the contents of the object. The SHA1 hash is a cryptographic hash function. What that means to us is that it is virtually impossible to find two different objects with the same name. This has a number of advantages; among others:

Git can quickly determine whether two objects are identical or not, just by comparing names. Since object names are computed the same way in every repository, the same content stored in two repositories will always be stored under the same name. Git can detect errors when it reads an object, by checking that the object’s name is still the SHA1 hash of its contents.

The Objects
Every object consists of three things – a type, a size and content. The size is simply the size of the contents, the contents depend on what type of object it is, and there are four different types of objects: “blob”, “tree”, “commit”, and “tag”.

A “blob” is used to store file data – it is generally a file.
A “tree” is basically like a directory – it references a bunch of other trees and/or blobs (i.e. files and sub-directories)
A “commit” points to a single tree, marking it as what the project looked like at a certain point in time. It contains meta-information about that point in time, such as a timestamp, the author of the changes since the last commit, a pointer to the previous commit(s), etc.

A “tag” is a way to mark a specific commit as special in some way. It is normally used to tag certain commits as specific releases or something along those lines.

Almost all of Git is built around manipulating this simple structure of four different object types. It is sort of its own little filesystem that sits on top of your machine’s filesystem.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Git Reset Vs Git Revert

rajeshkumar created the topic: git reset Vs git revert
git reset Vs git revert

The git revert command undoes a committed snapshot. But, instead of removing the commit from the project history, it figures out how to undo the changes introduced by the commit and appends a new commit with the resulting content. This prevents Git from losing history, which is important for the integrity of your revision history and for reliable collaboration.

git revert

Reverting vs. Resetting
It’s important to understand that git revert undoes a single commit—it does not “revert” back to the previous state of a project by removing all subsequent commits. In Git, this is actually called a reset, not a revert.\

Reverting has two important advantages over resetting. First, it doesn’t change the project history, which makes it a “safe” operation for commits that have already been published to a shared repository. For details about why altering shared history is dangerous, please see the git reset page.

Second, git revert is able to target an individual commit at an arbitrary point in the history, whereas git reset can only work backwards from the current commit. For example, if you wanted to undo an old commit with git reset, you would have to remove all of the commits that occurred after the target commit, remove it, then re-commit all of the subsequent commits. Needless to say, this is not an elegant undo solution.

git reset

If git revert is a “safe” way to undo changes, you can think of git reset as the dangerous method. When you undo with git reset(and the commits are no longer referenced by any ref or the reflog), there is no way to retrieve the original copy—it is a permanent undo. Care must be taken when using this tool, as it’s one of the only Git commands that has the potential to lose your work.

Usage

git reset

Remove the specified file from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.

git reset

Reset the staging area to match the most recent commit, but leave the working directory unchanged. This unstages all files without overwriting any changes, giving you the opportunity to re-build the staged snapshot from scratch.

git reset –hard

Reset the staging area and the working directory to match the most recent commit. In addition to unstaging changes, the –hard flag tells Git to overwrite all changes in the working directory, too. Put another way: this obliterates all uncommitted changes, so make sure you really want to throw away your local developments before using it.

git reset

Move the current branch tip backward to , reset the staging area to match, but leave the working directory alone. All changes made since will reside in the working directory, which lets you re-commit the project history using cleaner, more atomic snapshots.

git reset –hard

Move the current branch tip backward to and reset both the staging area and the working directory to match. This obliterates not only the uncommitted changes, but all commits after , as well.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: git reset Vs git revert
More Reference —

www.atlassian.com/git/tutorial/undoing-changes#!revert
www.atlassian.com/git/tutorial/undoing-changes#!reset
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

What is Staging Area?

rajeshkumar created the topic: What is staging area?
The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.

The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.

The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging area.

The basic Git workflow goes something like this:

You modify files in your working directory.
You stage the files, adding snapshots of them to your staging area.
You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

How to clean workspace in git?

rajeshkumar created the topic: How to clean workspace in git?
To reset a specific file to the last-committed state (to discard uncommitted changes in a specific file):

git checkout thefiletoreset.txt

This is mentioned in the git status output:

(use “git checkout — …” to discard changes in working directory)

To reset the entire repository to the last committed state:

git reset –hard

To remove untracked files, I usually just delete all files in the working copy (but not the .git/ folder!), then do git reset –hard which leaves it with only committed files.

A better way is to use git clean:

git clean -d -x -f

will remove untracked files, including directories (-d) and files ignored by git (-x). Replace the -f argument with -n to perform a dry-run or -i for interactive mode and it will tell you what will be removed.
you delete local files from your current branch?

git clean -f

But beware… there’s no going back. Use -n or –dry-run to preview the damage you’ll do.

If you want to also remove directories, run git clean -f -d

If you just want to remove ignored files, run git clean -f -X

If you want to remove ignored as well as non-ignored files, run git clean -f -x

Note the case difference on the X for the two latter commands.
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Customizing Git – Git Hooks

rajeshkumar created the topic: Customizing Git – Git Hooks
Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur. There are two groups of these hooks: client side and server side. The client-side hooks are for client operations such as committing and merging. The server-side hooks are for Git server operations such as receiving pushed commits. You can use these hooks for all sorts of reasons, and you’ll learn about a few of them here.

Installing a Hook

The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that’s .git/hooks. By default, Git populates this directory with a bunch of example scripts, many of which are useful by themselves; but they also document the input values of each script. All the examples are written as shell scripts, with some Perl thrown in, but any properly named executable scripts will work fine — you can write them in Ruby or Python or what have you. These example hook files end with .sample; you’ll need to rename them.

To enable a hook script, put a file in the hooks subdirectory of your Git directory that is named appropriately and is executable. From that point forward, it should be called. I’ll cover most of the major hook filenames here.

Client-Side Hooks

There are a lot of client-side hooks. This section splits them into committing-workflow hooks, e-mail-workflow scripts, and the rest of the client-side scripts
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

ERR! Error: failed to fetch from registry: gitlab-cli

rajeshkumar created the topic: ERR! Error: failed to fetch from registry: gitlab-cli
rajesh@mahto:~$ more /home/rajesh/npm-debug.log
info it worked if it ends with ok
verbose cli [ ‘/usr/bin/nodejs’,
verbose cli ‘/usr/bin/npm’,
verbose cli ‘install’,
verbose cli ‘gitlab-cli’,
verbose cli ‘-g’ ]
info using npm@1.1.4
info using node@v0.6.19
verbose config file /home/rajesh/.npmrc
verbose config file /usr/etc/npmrc
verbose config file /usr/share/npm/npmrc
silly exec /usr/bin/nodejs “/usr/share/npm/bin/npm-get-uid-gid.js” “nobody” 1000
silly spawning [ ‘/usr/bin/nodejs’,
silly spawning [ ‘/usr/share/npm/bin/npm-get-uid-gid.js’, ‘nobody’, 1000 ],
silly spawning null ]
silly output from getuid/gid {“uid”:65534,”gid”:1000}
silly output from getuid/gid
verbose cache add [ ‘gitlab-cli’, null ]
silly cache add: name, spec, args [ undefined, ‘gitlab-cli’, [ ‘gitlab-cli’, null ] ]
verbose parsed url { pathname: ‘gitlab-cli’,
verbose parsed url path: ‘gitlab-cli’,
verbose parsed url href: ‘gitlab-cli’ }
verbose addNamed [ ‘gitlab-cli’, ” ]
verbose addNamed [ null, ” ]
silly name, range, hasData [ ‘gitlab-cli’, ”, false ]
verbose raw, before any munging gitlab-cli
verbose url resolving [ ‘ registry.npmjs.org/ ‘, ‘./gitlab-cli’ ]
verbose url resolved registry.npmjs.org/gitlab-cli
http GET registry.npmjs.org/gitlab-cli
ERR! Error: failed to fetch from registry: gitlab-cli
ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
ERR! at Request. (/usr/lib/nodejs/request/main.js:212:58)
ERR! at Request.emit (events.js:88:20)
ERR! at ClientRequest. (/usr/lib/nodejs/request/main.js:412:12)
ERR! at ClientRequest.g (events.js:156:14)
ERR! at ClientRequest.emit (events.js:67:17)
ERR! at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
ERR! You may report this log at:
ERR! < bugs.debian.org/npm >
ERR! or use
ERR! reportbug –attach /home/rajesh/npm-debug.log npm
ERR!
ERR! System Linux 3.8.0-34-generic
ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “gitlab-cli” “-g”
ERR! cwd /home/rajesh
ERR! node -v v0.6.19
ERR! npm -v 1.1.4
ERR! message failed to fetch from registry: gitlab-cli
verbose exit [ 1, true ]
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

npm ERR! error installing node-gitlab@0.2.1

rajeshkumar created the topic: npm ERR! error installing node-gitlab@0.2.1
rajesh@mahto:~$ npm install node-gitlab
npm http GET registry.npmjs.org/node-gitlab
npm http 304 registry.npmjs.org/node-gitlab
npm http GET registry.npmjs.org/debug
npm http GET registry.npmjs.org/restful-client
npm http 304 registry.npmjs.org/restful-client
npm ERR! error installing node-gitlab@0.2.1

npm ERR! Error: No compatible version found: restful-client@’>=0.1.0- <0.2.0-' npm ERR! No valid targets found. npm ERR! Perhaps not compatible with your version of node? npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:488:10) npm ERR! at next_ (/usr/share/npm/lib/cache.js:438:17) npm ERR! at next (/usr/share/npm/lib/cache.js:415:44) npm ERR! at /usr/share/npm/lib/cache.js:408:5 npm ERR! at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7) npm ERR! at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7) npm ERR! You may report this log at: npm ERR! < bugs.debian.org/npm >
npm ERR! or use
npm ERR! reportbug –attach /home/rajesh/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.8.0-34-generic
npm ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “node-gitlab”
npm ERR! cwd /home/rajesh
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: restful-client@’>=0.1.0- <0.2.0-' npm ERR! message No valid targets found. npm ERR! message Perhaps not compatible with your version of node? npm ERR! Error: EACCES, open 'npm-debug.log' npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! npm ERR! System Linux 3.8.0-34-generic npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "node-gitlab" npm ERR! cwd /home/rajesh npm ERR! node -v v0.6.19 npm ERR! npm -v 1.1.4 npm ERR! path npm-debug.log npm ERR! code EACCES npm ERR! message EACCES, open 'npm-debug.log' npm ERR! errno {} npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/rajesh/npm-debug.log npm not ok rajesh@mahto:~$ npm -v 1.1.4 rajesh@mahto:~$ node -v The program 'node' can be found in the following packages: * node * nodejs-legacy Try: sudo apt-get install
rajesh@mahto:~$ sudo apt-get install node
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

My Gitlab First Notes…

rajeshkumar created the topic: My Gitlab First Notes…
To work in gitlab, login as a scmadmin
su – s ( go to root)
su – git 9 go to as a git user)

To see the config –
cd /home/git/gitlab/config
more gitlab.yml
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u

rajeshkumar created the topic: FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u
FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Error

gitlab-ctl reconfigure
Starting Chef Client, version 11.12.2
Compiling Cookbooks...
Recipe: gitlab::default
* directory[/etc/gitlab] action create (up to date)

================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb
================================================================================

RuntimeError
------------
External URL must include a FQDN

Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:95:in `parse_external_url'
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:191:in `generate_config'
/opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:34:in `from_file'

Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:

88:
89: def parse_external_url
90: return unless external_url
91:
92: uri = URI(external_url.to_s)
93:
94: unless uri.host
95>> raise "External URL must include a FQDN"
96: end
97: Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
98: Gitlab['gitlab_rails']['gitlab_host'] = uri.host
99: Gitlab['gitlab_rails']['gitlab_email_from'] ||= "gitlab@#{uri.host}"
100:
101: case uri.scheme
102: when "http"
103: Gitlab['gitlab_rails']['gitlab_https'] = false
104: when "https"

Running handlers:
[2014-11-03T12:38:40+05:30] ERROR: Running exception handlers
Running handlers complete

[2014-11-03T12:38:40+05:30] ERROR: Exception handlers complete
[2014-11-03T12:38:40+05:30] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.925307977 seconds
[2014-11-03T12:38:40+05:30] ERROR: External URL must include a FQDN
[2014-11-03T12:38:41+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

more /etc/gitlab/gitlab.rb
# Check and change the external_url to the address your users will type in their browser
external_url ‘hostname:9999’
unicorn = 9090

Log file

Dumped to
/opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out

OS
RHEL 6.5
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u
Solved after
hostname.dev.corp.local:9999
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited u
I am still not able to access the gitlab url from browsers…with following info….
gitlab-ctl show-config
Starting Chef Client, version 11.12.2
Compiling Cookbooks…
{
“gitlab”: {
“bootstrap”: {

},
“user”: {

},
“redis”: {

},
“gitlab-rails”: {
“secret_token”: “f276844818b47932ab27c670536111f68d4ad8d84e3d02a42a0f8be23e00c78a0094f62efbd08655f3430a9524258f39b82281e10d52c391c2e751f5747d45dc”
},
“gitlab-shell”: {

},
“unicorn”: {
“port”: 9090
},
“sidekiq”: {

},
“nginx”: {

},
“logging”: {

},
“remote-syslog”: {

},
“logrotate”: {

},
“high-availability”: {

},
“postgresql”: {

},
“web-server”: {

}
}
}
Converging 0 resources

Running handlers:
Running handlers complete

Chef Client finished, 0/0 resources updated in 10.57749914 seconds

gitlab-ctl status
run: logrotate: (pid 19510) 136s; run: log: (pid 10239) 4278s
run: nginx: (pid 20043) 2s; run: log: (pid 9765) 4365s
run: postgresql: (pid 19516) 135s; run: log: (pid 9569) 4393s
run: redis: (pid 19524) 135s; run: log: (pid 9432) 4475s
run: sidekiq: (pid 19529) 134s; run: log: (pid 9712) 4371s
run: unicorn: (pid 19534) 134s; run: log: (pid 9664) 4377s

more /etc/gitlab/gitlab.rb
external_url = ‘xysudyd.dev.corp.local:9999’
unicorn = 9090
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :