How to Git clone your remote repository
Hi, I am Malathi Boggavarapu and welcome to my blog.
This tutorial describes how to clone the remote repository to your local machine and try out different commands to know about the commits that were made in the repository and we also talk a bit about branches and tags. I have a seperate post "Git Fundamentals" in my blog which explains everything about Git but i had broken them down to smaller sections to make it easy for everyone to follow. This post will only introduce you to Git.
So let's get started.
Working remotly with Git
Let's look at cloning our remote repository to our local machine. In our example i use jquery repository on github.
git clone https://github.com/jquery/jquery.git
This is going to download the entire history of the project, all of the commits that have been made to the jquery repo. You can use git log command to see the commits that have been made to the project. To see more condensed version, use git log --oneline. You can see commit per line.
Basic repository statistics
git log --online | wc -l - If we want to know how many commits exists in the repo, you can use word count (wc) along with -l (alphabet l).
git log --online --graph - Provides graph on left hand side showing difft branches and merges that happened. So we can see how the history of the project is changed. If you see the below picture, on the left hand side, you see graph which indicates different branches and merges for various request that were made.
git shortlog - It lists all the authors and commit messages for each of them. It also provides number of commits each author has made. See below.
git shortlog -sne
s -> If i don't want to have individual commit messages and want summary,
n -> orders numerically by number of commits.
e -> include users email addresses.
See the below example when we use options sne to the shortlog. The first column is number of commits that were made by the user and second column is the user name and thrid column is their corresponding email address.
Viewing commits
We can also take a look at any of the commits that were made.
git show HEAD - what is the last commit made for the query project.
git show [commit hash] - It shows all the changes that were made under the particular commit by identifying using commit hash.
git remote - It shows that we have got one remote called origin. origin is the git default name from where the source come from.
git remote -v - It shows both the urls for fetch and push for that particular remote.
See the below picture
Viewing Branches and Tags
git branch - You can view all branches in your repository.
git branch -r - Display remote branches
Branches are often used for temporary working copies, to seperate main line development from bug fixes.
git tag - Display tags. These are stable points and known points in your codebase where you can often tag versions.
Follow my other posts on Git which were mentioned below
Brief History of Version Control Systems, DVCS Advantages and Git Installation
Configuring Git in your computer
Working locally with Git
Git Fetching, Pulling from Remote repository and Pushing to Remote repositoryGit - Creating, Verifying tags and Pushing to Remote repository
Branching, Merging and Rebasing with Git
Git - Branching, Merging, Rebasing and Cherry-picking
Happy Learning!!!
Comments
Post a Comment