Skip to main content

Git Fundamentals and useful command to use


 

 

 

Create Repo from GitHub site.

Step 1. Create a local source control path

Step 2. Got to Git Bash

Step 3. initialize the git

 

 

 

Linked or remote origin

$ git remote add origin "https://github.com/shubh1984/SampleProject.git"

 

 

 

Pull

$ git pull origin master

 

 

Status

$ git status

 

 

Adding file to local repo

$ git Add file name

$ git add -A      [add all]

 

 

Commit

$ git commit filename -m "commit comment"

$ git commit -a -m "commit comment"    [commit all]

 

 

Push to remote server

$ git push  origin master

$ git push -f origin master

 

 

Fetch [need to do merge]

$ git fetch origin master

If server file is updated than need to do Fetch

 

Check the commit logs

$ git log

 

 

 

 

 

 

Get list of files

ls

 

 

Branching

There are two branches local and remote-tracking branches

  1. Creating different branch

$ git branch devbranch

  1. Switching from master to new devbranch

$ git checkout devbranch

  1. Similar way create and add new files in dev branch

 

 

 

 

Merge in-between branch

$ git merge origin/master

 

 

 

Rebasing

shubh@LAPTOP-SDS90F74 MINGW64 /c/GitRepos/DesignPatternLocal (master)

$ git rebase devbranch

 

 

Push to centra repo

$ git push origin devbranch

$ git push origin master

 

 

Revert

$ git checkout 894e167 revert.txt

 

 

Creating key to stop public publishing

$ ssh-keygen

$ cat /c/Users/shubh/.ssh/id_rsa.pub

Update the SSH key in github setting.

 

  • Authenticate

$ ssh -T git@github.com

Enter the pass phrase

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCr1XkZX06v9GlSXGMZ5DBZAha0Xnqa0l2aYVQld2abQVxq7N4v8aJoNua1RtWygrsSLeEgcCyirlh8z+m5yGaV8TCZQJDNYv/CgqCVZYTN9T6OmaC6DEFfs6WNjLs9+hvPKDE7xHlUvr/ctFIoK9EDowY0nmQP64cEOVXCEo+uvBFK/mYPfk6VSWY4sPAQ2K+xGHoGXxNzly0/y0wCXqIegQU1pTHzbHfJeGEA9gTuvSGe3sayTNmFvZr2F5knl2dJDgbxGQWn/F6Mr7Vt3vd8OVpaaDdqub59inAviZq2cGdgu1Flgg8s7ZUpEvXfdKyU/cGluJmTSRqs8Hy88t7sDklyQPfrW5VKApZ7M0/P4fNKGUFM+FU+Vphph6oKYLjtCMjEMrphIMgsz9yKWemiLKMY8V2zYkl7E9geQEbjbXPOtLUAcFAfeYzT+j8nR3Ikbr1Nx4q+UJK9ceBg5SxwPCXwBrhFUTFr/gdVqkg4j1V0Pjfw96brij21aXreAB8= shubh@LAPTOP-SDS90F74

 

Comments

  1. The 13 Best Casino Restaurants in Milwaukee, Wisconsin
    This is an interesting piece of information that can 양주 출장샵 help inform your gambler's decision making. 순천 출장샵 For 아산 출장안마 instance, the casino serves up a wide 공주 출장샵 array 여주 출장마사지 of table

    ReplyDelete

Post a Comment

Popular posts from this blog

Git fundamental and useful command to use - version-2

      Install Git your local machine Link: Git - Downloads (git-scm.com) Version : git version 2.31.1.windows.1   Know the version $ git --version   Git help for command $ git help config $ git config --help Prompt the git config help file in browser Make a directory $ mkdir shubhapp$ mkdir shubhapp $ cd shubhapp/ - go to directory   initialize the git $ git init Initialized empty Git repository in C:/Users/shubh/shubhapp/.git/   Create a file Hello.txt   Add this file to git $ git Add hello.txt   Commit the changes $ git commit -a -m "commit comment"   Connect to remote github $ git config --global user.usern...

Min Cost to Connect Ropes problem solution using PriorityQueue using C#

Given n ropes of different lengths, we need to connect these ropes into one rope. We can connect only 2 ropes at a time. The cost required to connect 2 ropes is equal to sum of their lengths. The length of this connected rope is also equal to the sum of their lengths. This process is repeated until n ropes are connected into a single rope. Find the min possible cost required to connect all ropes. Input: ropes = [ 8 , 4 , 6 , 12 ] Output: 58 Explanation: The optimal way to connect ropes is as follows 1. Connect the ropes of length 4 and 6 (cost is 10 ). Ropes after connecting: [ 8 , 10 , 12 ] 2. Connect the ropes of length 8 and 10 (cost is 18 ). Ropes after connecting: [ 18 , 12 ] 3. Connect the ropes of length 18 and 12 (cost is 30 ). Total cost to connect the ropes is 10 + 18 + 30 = 58 public static void Demo() { //int[] Ropes = { 4, 3, 2, 6 }; //int[] Ropes = { 8, 4, 6, 12 }; int[] Ropes = { 1, 2, 5, 10, 35, 89...

Given an array of integers, and a target value determine if there are two integers that add to the sum using C#

Given an array of integers, and a target value determine if there are two integers that add to the sum.