WHAT'S NEW?
Loading...
Showing posts with label git. Show all posts
Showing posts with label git. Show all posts
I. Configuration

git config --global user.name "your_username"
git config --global user.email "your_email"
this sets the author's identity inside git.

Initializing and Starting Tracking Projects
to initialize a directory as the directory to be tracked for changes, navigate to the directory that is to be tracked and run the command
git init

what this does is create a folder named .git into your the current directory which git uses to track the changes made.

now you can start making changes to the current directory. you can add files, delete them or edit some files. All these activities are tracked and git is informed about the changes made.

suppose you add a file named test.html
to observe the changes made, you can run this command
git status

to add the changed file to the staging index (before you make commit, you should stage the files), simply run the command
git add test.html

to commit the changes, run this command
git commit test.html -m "Your commit message is here"
e.g. git commit test.html -m "Initial commit"

Viewing logs of commits
git log   #displays all commit logs
git log -n 5  #displays 5 latest commit logs
git log --since=2015-04-05  #displays commits since the date specified
git log --until=2015-05-07  #displays commits until the date specified
git log --since=2015-04-05 --until=2015-05-07  #combination of since and until
git log --author="Bikash"  #displays commit logs by the specified author
git log --grep="Init"  #regular expression based searching of logs; search is made on commit messages

suppose we have a commit message "New file created"
we can search for log of this commit  as:
git log --grep="New*"
more information about regular expressions will be in a session in this blog.

Life was easy, projects were small; there weren't more files to handle and tracked for changes. Many project files got misplaced and many got deleted. A part of hard work couldn't be saved because of lack of knowledge. Saved works couldn't be indexed so that I could access different versions of my code within same repository.

HEARD OF VERSION CONTROL SOFTWARE LONG AGO, BUT COULDN'T GRAB THEM FOR PRACTICAL USE.

Now here comes the requirement of version control software and lets get started.

Git is the  most popular version control software that helps to track different versions of  our code and let us move back and forward to different versions. So, in case we get messed up with our code and need to get some previous working versions of our code, its GIT that provides us the power to get our requirement.

GIT helps us to track every changes made in our project directory. It creates something like mapping of the changes made in our projects. And we can navigate to different locations in the map created by git to undo changes or redo changes made.

GIT uses three layer architecture for version control mechanism namely working, staging index and repository. When we make some changes in our project directory, the files are in the "working" state. After we call "git add" command these changes are shifted to the "staging index" and finally on "git commit" command, they are moved to the "repository". Likewise all the files use this three layer workflow.
If you know what git is then go ahead and if you don't know what it is, I will make  a post on that too.
Identity
git config --global user.name "User Name"
git config --global user.email user@yourdomain.com
Settings
git config --list
View Identity
git config user.name
git config user.email
Help
git help config
Initializing a Repository in Current Directory
git init
To traverse from one directory to another, linux based commands are to be used.
Cloning a Repository
git clone clone_url
Checking status
git status
Add file for tracking
git add filename
Commit Changes
git commit -m 'comments about the commit or description of the commit'