Exploring git life-cycle

Exploring git life-cycle

In this blog we will see the basic life-cycle of a file in git. Refer below diagram.


Round 1 Changes

I have created the ‘git-learning’ repository using GitHub. Initialized the repository using the README.md file. That is my initial commit on the master branch. See below unique commit id: 1d4ce0714c2e9a8d873c1a5e97cc0ce7bc12fd1b

As of now we have only one branch that is master, we can create other branches also, that we will cover later.

I have cloned the repository & run git log list down the version history for the current branch i.e. master. Showing all information like when & who performed the commit.

Lets do some changes in README.md file. After that run git status

So after changing the file, git saying there is ‘Changes not staged. Use git add to update….’ i.e. there are some changes in your working area. Let’s run the git diff to see the changes.

Let’s run git add command to move the changes from working to staging area & see the git status again.

Here if you notice that, git is saying you are up to date with master. You have staged your changes, now ready for commit. It is also showing changes to be committed.

Here if you run git diff, it will not show any data, as you have pushed changes in staging area. You have to run the git diff –staged

Let’s commit our changes using git commit command. This will move the changes from staging area to local repository & records file permanently in version history.

You have committed your changes. Permanently noted in version history locally. This commit is not available in remote repository. Check latest commit id using git log.

commit 77016c10f68af68b355884bdce65e98f6e7642bc

Notice below screenshot the red line ‘origin/master, origin/Head‘ – is on previous commit. Which is remote repository latest commit. Local repository latest commit is on top, that we have done above.

You can compare the commits using git diff <new-commit-id> <old-commit-it>

Final thing is to push the changes in remote repository using git push

git push is done i.e. local commits uploaded to remote repository. Checking remote repository:

commit 77016c10f68af68b355884bdce65e98f6e7642bc

Check git log now. After push, notice the red line ‘origin/master, origin/Head‘ – is now present on latest commit.


Round 2 Changes

I have added two new files & changed the README.md

Checking git status

Checking git diff

Moving all changes to staging area: git add . –all

Commit & Checking git log

commit: 177a091e9b72c3b97799aaac97c5ffa8e7478c23

Final git push.


Restoring Files (git restore)

When you have changed file in workarea & want to restore with original one. Run git restore <file> command.

When you have staged the file in staging area & want to restore. Run git restore –Staged <file> command.

Reset Commit (git reset)

I have commit the change in local repository & commit got generated f975da9d4ecb7c45db061b72fd1b450fd61cfa0f. Now want to reset the commit.

Lets reset to last commit. i.e. 179359643be893c489a61b50233752a299b01f4a

Lets run git reset –soft HEAD1 command to reset to last commit

Provide HEADn for nth last commit.

Thanks!

Happy Learning! Your feedback would be appreciated!

GitHub Repository – Configuring/Cloning

GitHub Repository – Configuring/Cloning

In this blog we will explore the basics of git repository. Git – Open source version control system for tracking changes in source code during software development. I have used github.com/ to create a repository for objects versioning. We will explore below topics in this blog. 

  • Installation of git in the Linux, Windows OS & configuration.
  • Generating ssh key for authentication git-hub account.
  • Clone the existing git-hub repository in local environment.
  • Pushing changes from local cloned repository to remote repository.

Install git:

  • To install the git in Linux: sudo apt-get install git
  • For Windows you can download it from : git-scm.com Check the version after installation
check

Below configuration required.

git config --global user.name "<<username>>"
git config --global user.email "<<email>>"

Generation SSH keys:

You can setup the ssh keys so that very time you don’t have to provide username & password for git repository while pushing changes. Refer this blog for more details help.github.com

Below command create the public & private ssh keys for your system.

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ ssh-add ~/.ssh/id_rsa

Key for Linux & Windows:

linux
win

The public key present in id_rsa.pub file you need to copy that & set in your git-hub settings. You can have multiple keys in git-hub account.

keys

Cloning existing git-hub repository:

You can clone the remote repository in your local environment. After that you can make changes & later push to remote location.

Created a repository using the github.com/

repocrete

Repository Created: I have some files in it. Copy SSH link so that we clone the repo.

test
git clone git@github.com:shobhit-singh/test-dev-repo.git

clone
After doing some changes in any file you can check the status of git.

git status
status

Pushing local changes to remote repository:

To push the changes from local to remote repository.

git add . --all
git commit -m 'insert comments here'
git push
git push

Checking object in git-hub:

git

Commands:

git clone git@github.com:shobhit-singh/test-dev-repo.git
git status
git add . --all
git commit -m 'insert comments here'
git push

For creating new repository from command line refer this blog: GitHub Repository Creation – Command Line


Thanks!

Happy Learning! Your feedback would be appreciated!

GitHub Repository Creation – Command Line

In this blog we will explore how we can add new repository in GitHub using  API & adding the new project in that repository.

For configuring git refer this blog: Exploring Git – Configuring GitHub Repo


Creating GitHub Repository:

Let’s create a empty repository in git-hub using the API.

sudo apt install curl
curl -u ‘username’ https://api.github.com/user/repos -d ‘{“name”:”first-project”}’

curl

Empty repository has been created in git-hub account, copy the remote URL.

github

Creating Project Files:

I have created project folder ‘first-project’  in local environment inside that one file is created.

1

Initializing, Add & Commit

Initializing the new project using git init, adding the protect to stage using git add & commit.

inti

Adding URL & Push:

Using below commands you can push your local code in remote new git repository.

push

Check the files in git-hub repository.

creatd repo

Commands:

 
$ sudo apt install curl
$ curl -u 'shobhit-singh' https://api.github.com/user/repos -d '{"name":"first-project"}'

$ git init
$ git add .
$ git commit -m "Initial commit"
$ git remote add origin git@github.com:shobhit-singh/first-project.git
$ git remote -v
$ git push origin master

 

To clone existing repository : Refer this blog Exploring Git – Configuring GitHub Repo


Thanks!

Happy Learning! Your feedback would be appreciated!

ODI 12c | Version Control System Setup – Git

In this blog we will see step by step how we can setup the version control in ODI 12c using git. Git – open source version control system for tracking changes in source code during software development. I have used github.com/ to create a repository for my ODI 12c objects versioning.


Step 1: Created a repository using the github.com/

1

Copy the git url for you repository.

https://github.com/shobhit-singh/odi12c-repo.git

2

Step 2: Open the ODI Studio & change your “Version Control Management System” to git by default it was set to ODI.

3

4

Step 3: Setup the git, go to setting & edit connection.

5

Provide the git url, github repository. Change the authentication to SSL.

6

Accept the server certificate.

7

Step 3: Clone remote repository with local folder.

8

9

10

Step 4: Click on configure to setup the branch. I have selected the master branch & save the settings.

11

12

Adding ODI Object First Time in VCS:

I have created the Model Folder, Sub-Model Folder, Model & Data-store in ODI.

datastore

Right Click on the Model Folder & Add to VCS, as it was new object & going first time.

13

You can select object also if you want to move child objects also. Add comments & Click on OK.

14

15

You can check the ODI Objects in GitHub.

Check the objects

Re-Adding ODI Object in VCS:

I have changed the data-store ‘TEST_TABLE’ in ODI. I have added the column in data-store. Now I have create a new version for this object. See below steps to create new version.

16

Add comments & Click on OK.

17

18

Check the version in GitHub: Now this object has 2 version.

19

 


Thanks!

Happy Learning! Your feedback would be appreciated!