Git Workflow (Pushing and Pulling) (PART-1)

Share via:

Dear Readers,

In this article,we will see Push Commits from Local Repository to Central Repository

Implementation Steps

  1. Create GitHub Account.
  2. Create Central Repository in GitHub Account.
  3. Create a new directory and Initialize as Git Local Repository.
  4. Create a new file and put some content in workspace.
  5. Adding file to Staging Area.
  6. Commit the file into Local Repository.
  7. Connect your Local Repository to Central Repository (GitHub).
  8. Create a new directory and Initialize as Git Local Repository.
  9. Push Commits to Central Repository.
  10. Verify files in Central Repository.
  11. Add Content to an existing file.
  12. Adding file to Staging Area.
  13. Commit the file into Local Repository.
  14. Push Commits to Central Repository.
  15. Verify files/commits in Central Repository.

Step 1 :

Create a GitHub Account

Check below link to create GitHub Account.

Create a new GitHub Account

Step 2 :

Create an Central Repository in GitHub Account

Logging to GitHub Account

Provide username and password and click on Sign in.

Click on Create a repository.

Specify Repository name “centralgit” and click on create repository.

The Repository “Ramesh-ktexperts/centralgit” has been created successfully.

Step 3 :

Create a new directory and Initialize as Git Local Repository

Create a new Directory “mumbaigit”

Go inside the directory “mumbaigit” and initialize git repository

To see the local repository
.git is the local repository.
By default,it will be hidden.(shouldn’t deleted)
Commits will be store in local repository (.git)

Step 4 :

Create a new file and put some content in workspace

Create a new file and put some content 

To see the status of git

Note
we have seen the untraced file(newfile) i.e,is in red colour.
wherever you create/modify files i.e,work space.
Staging area is virtual,we can’t see the staging area.

Step 5 :

Adding file to Staging Area

Add

We should add the file to staging area.
Send file from Workspace to Staging Area.

To see the status of git

Note
The file has been sent to staging area.
The staging area responsible to take snapshot of file.
Here,we can see the file is in green colour.
It means the staging area has taken the snapshot of file automatically.

Step 6 :

Commit the file into Local Repository

Commit

We need to commit the file then only the file will come from staging area to Local Repository.

Note
The file has been committed successfully.
we can see 1 file has changed (we have file) and 1 insertion(+)(kept one line inside the file).
Now,the file is in Local repository in the form of commit.

To see all the list of commits

Note
we can see commit id,it has 41 alphanumeric characters.
Commit will contains name,email,date,month,time and including year.
we can see the message which was you given.

To see the data of commit id

or

Note
We can give whole commit id or give first seven characters from commit id.
We have to give minimum seven characters.

Step 7 :

Connect your Local Repository to Central Repository (GitHub)

Go inside GitHub and open your Central Repository.

Copy the below command and paste in mumbaigit.


When you add the central repository address will be stored in Local Repository.

Step 8 :

Push Commits to Central Repository
Origin represents central repository URL.
Master (pushing to master branch).
here -u is not mandatory.

Step 9 :

Verify files in Central Repository

Go inside your GitHub and hit refresh of your browser.

we can see file and commit message.

To check data of the file

Click on myfile to open.

We can the data “first line from mumbai” of file.

Step 10 :

Add Content to an existing file

Using vi Command

To see the status of git

Step 11 :

Adding file to Staging Area

Add

We should add the file to staging area.
Send file from Workspace to Staging Area.

To see the status of git

Step 12 :

Commit the file into Local Repository

Commit

To see the list of commits

To see the data of second commit

Note
+ indicates the data of current commit.

Step 13 :

Push Commits to Central Repository

Step 14 :

Verify files/commits in Central Repository
Go inside github and see the files/commits.

Here,we can see 2 commits and file which has latest commit message.

To check data of the file
We can see 2 lines in the file.

Click on myfile to open.

We can see data of the file.

To see the data of commits

Go inside Commits

Click on 2 commits to open.

We can see 2 commits are latest commit and previous commit.

To see the data of previous commit

Click on latest commit “2nd commit from mumbai”.

We can see the data of latest commit along with whole data.

+ indicates the data of latest commit.

To see the data of previous commit

Click on previous commit “1st commit from mumbai”

We can see only the data of previous commit.

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTEXPERTS is always active on below social media platforms.

 

Facebook : https://www.facebook.com/ktexperts/
LinkedIn   : https://www.linkedin.com/company/ktexperts/
Twitter     : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform

Follow Me
Ramesh’s Linkedin : https://www.linkedin.com/in/ramesh-atchala/

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

2 thoughts on “Git Workflow (Pushing and Pulling) (PART-1)

Add Comment