Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Friday, 1 February 2019

Let's Learn - Git - Pull Specific Folder - sparsecheckout


What if your git repository has lots of folders but you have to work on a specific file in a particular folder. This git feature is called Sparse checkout. Previous Versions of git doesn't support this feature which forces you to download the whole repository. Sometime repository is too big to download and time-consuming process.

Current git versions support Sparse checkout which allows you to clone or fetch only a particular folder from a very big repository. Let's see how we can achieve it.

Task - Need to sync a folder named 'other' from 'DataGenX' repository 

Step #1: Initialize the Repository
Create a folder where you want to sync your git repo folder and Initialize git



Step #2: Add the Remote Repository
Add the remote Git repository with this local git repo as below -



Step #3: Create and Checkout a branch [Optional Step]
Creating of the branch is a totally optional step but it is advisable to create.



Step #4: Enable the Sparse Checkout Properties
Now, we have to enable the Sparse checkout properties and adding the folder name (in our case - 'other') in property file which we want to sync.



Step #5: Pull the Specific Folder
This is the last step where we pull the specific folder as below -

git pull <remote> <pull_branch_name>  #not locally created


while running this command, need to give proper branch name from where you want to pull the data, In our case, it is master.

Step #6: List and work with synced directory



Commands as below - 
==




Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Sunday, 25 November 2018

Let's Learn - Git Branching #2


Continuing from the last post Let's Learn - Git Branching #1 where we have learned about git branches, how to create and do the parallel development with them.

a. Merge the changes to master:  we have completed development with branch "atul" and ready to merge those changes/module with the main branch "master". If there are no changes have been done in master after creating "atul" branch, merging process is quite easy. We will look into this first -

i. Git log of "atul" branch: 
==

From the screenshot, we can see that "atul" branch has initiated from "master" branch from below commit point -
master -  de70bc2450802c80dc5520afa20b53de30488e5a
atul -  781d0bb325d67ba251e9db3af4d8ef90c246e406

ii. Git log of "master" branch: Let''s quickly check the master log as well


In master branch, last commit where the HEAD is pointing to "de70bc2450802c80dc5520afa20b53de30488e5a" same commit which we can see inside "atul" branch which tells us that there is no changes have been done in master after branching "atul" out.

This kind of merge is simple, as this is just a repoing of HEAD and done. Let's see how we can merge -
==

This command will merge the "atul" branch changes to "master", we can confirm the same from master git log.


Let's quickly make a new change in the master branch and check the git log







after committing the changes (third.txt) to master, git log shows that HEAD point to the latest change






Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Thursday, 22 November 2018

Let's Learn - Git Branching #1


Git branching feature is the most notable feature provided by Git for parallel development without impacting other developers. Using git branches, Developers can work on different module parallel with same base code and merge them later into one to build the complete picture.

We will start with the simple branching scenarios, where 2 branch has been initiated with same base code and merge them into one after few modifications.

a. List Git Branch:
==

b. Create Git Branch:
==

By above command, you can create a branch which has the same base code as master and when you list the branch, now you can see 2 names - atul (branch we created) and master (original). Asterisk * sign will tell us which repo is currently active.


c. Switch to Git Branch (checkout branch): 
===
To checkout branch is very easy and can be done by above command quickly. Just remember that whatever changes you have done in this branch will be local (remain) in this branch only.

d. Let's make some changes in the branch:
To make some changes, what I have done is created a new file name "atul.txt" and committed to this branch named "atul". You can found all the commands as below -
= =

now, we have made the changes, let's check the git log for this branch -


Here we have to understand one important branching concept, as you can see there are 2 branches (master and atul) pointer.

origin/master, master - this pointer will tell this branch "atul" has been branched from "master" from this commit de70bc2450802c80dc5520afa20b53de30488e5a

HEAD -> atul, origin/atul - this pointer will tell you that HEAD is pointing to "atul" branch means you are inside "atul" branch and commit 0ba89ab2d62a74c48951ba20b2c0f369c9a675a3 has been done

Let's quickly move to master branch and check whether these changes are there or not ??

e. Moving back to master:
Moving back process is the same as moving into the branch and check the git log in "master" branch


Here you can see that changes which we have committed inside "atul" branch hasn't been reflected in "master" branch.

This is how Git support Parallel Development with branching where the developer can create their own branch and develop the different features parallel.

f. What's the differences: 
We have created 2 branches named: "master" & "atul" and made some additional changes inside "atul" branch and commit to it. We can check the difference between these 2 branches by executing below command :
==

We will discuss about how to interpret this diff report in the next post, till then.....Happy Learning........





Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group     


Thursday, 15 November 2018

Let's Learn - Lifecycle of Status of Git Files


In previous post, we have started with the account creation, Basics Git Commands ( Git Basics #1 and Git Basics #2) and Setup of password less Git push (https://buff.ly/2DBrQPl), Continuing the same here with adding a new Git post in Let's Learn series where we will learn about different file status while making the changes into git repository.


©git-scm.com

There are 4 type of status of files under git repository.

Untracked:  New Files under git repo about which git don't aware of.

Unmodified: File has been pulled from remote repo to local and not has any modification
* when you pull any git repository to your local, all files are tracked and unmodified.

Modified: Files which have been changed from last pull

Staged: Files which have been modified from last commit and staged (git add command) for commit to remote repo.






Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group