Sunday, September 20, 2015

Git Learning Part II Inspecting a repository

Git status command displays the status of the working directory and the staging area. This doesnt give any information regarding the committed project history. Instead it gives info only about the changes in the staging area which have been staged, which havent been and which files have been tracked by Git. 

to use status command, can just use 

git status

Running this command on one Linphone git directory, below is what is seen. 

Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

modified:   Classes/LinphoneManager.m
modified:   Resources/linphonerc~ipad
modified:   linphone-Info.plist
modified:   linphone.xcodeproj/project.pbxproj
modified:   submodules/belle-sip (modified content)
modified:   submodules/linphone (modified content)

no changes added to commit (use "git add" and/or "git commit -a")

Ignoring Files : There can be two types of files those can be ignored. Those could be the ones just added or could be the ones that doesnt need to be committed to the git. The git status command will print both these types if the latter is not added to the ignore list. To add to the ignore list, these file paths can be specified in a .gitignore file. Below is a sample in which the Classes/LinphoneManager.m is excluded from appearing in the git status output. 

build-*
*.locuser
.DS_Store
liblinphone-sdk
liblinphone-iphone-sdk*.zip
xcuserdata/
Classes/LinphoneIOSVersion.h
Pods/
build
test-reportl
Classes/LinphoneManager.m

The Git log command displays the committed snapshots. this lets to list the project history, filter and search for the specific changes. Like mentioned earlier, git log command only works on the committed changes not in the working directory unlike the git status command. 

Some of the git log commands are like below

git log 
git log -n
git log —-onleline 
git log —stat => Displays which files are in each commit
git log -p => Displays patch of each commit 

git log —-author=“authorpattern>”
git log —-grep=“grep pattern>”
git log since> Shows only occurrence between a committ ID, branch name HEAD or any commit reference
git log file => Displays only commits that occur in a specific file. 
git log —-graph —-decorate —-oneline => Displays a text based graph to the left of the commit. —decorate adds the names of branches or tags of the commits that are shown. 

When listing the commit details it will be something like below 

commit 89a4eef409b30ab4007dbb704be2dfb3791e445b
Author: Steve keexo
   
In this the ID is the SHA-1 checksum of commits contents. this serves as unique ID and integrity of the content. 

References:



No comments:

Post a Comment