Tuesday, 20 February 2018

Git bash basic commands for online visual studio project


what is Git ?

  1. Version Control.
  2. Distributed version control system.
  3. Flexible
  4. Simultaneous development
  5. Faster releases
  6. Strong community support

Basic

  1. Branches
  2. Files and commits
  3. Pull requests
  4. Merge Branches


Packages:


Git BASH : Command line utility for suite for both window and LINUX.
Git GUI : For Windows users having GUI, it is alternative to Git BASH.
Shell Integration:  Integrated with Win folder where we can simply right-click and play with the integrated BASH or GUI options.

For windows Install Git from  https://git-scm.com/download/win



Basic Commands







$ help
GNU bash, version 4.3.46(2)-release (x86_64-pc-msys)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

$ git status
fatal: Not a git repository (or any of the parent directories): .git

$ git init
Initialized empty Git repository in D:/Raj kumar/Work/Code/.git/


Cloning into 'OTest'…

Go to rajdev.visualstudio.com
> Project
> Code
> Clone (right side)
> generate git credentials


Cloning into 'OTest'…
remote:
remote:                    vSTs
remote:                  vSTSVSTSv
remote:                vSTSVSTSVST
remote: VSTS         vSTSVSTSVSTSV
remote: VSTSVS     vSTSVSTSV STSVS
remote: VSTSVSTSvsTSVSTSVS   TSVST
remote: VS  tSVSTSVSTSv      STSVS
remote: VS   tSVSTSVST       SVSTS
remote: VS tSVSTSVSTSVSts    VSTSV
remote: VSTSVST    SVSTSVSTs VSTSV
remote: VSTSv        STSVSTSVSTSVS
remote:                VSTSVSTSVST
remote:                  VSTSVSTs
remote:                    VSTs    (TM)
remote:
remote:  Microsoft (R) Visual Studio (R) Team Services
remote:
Receiving objects: 100% (399/399), 14.86 MiB | 1.14 MiB/s, done.
Resolving deltas: 100% (312/312), done.

-------------------------------------------------


$ git branch
* master


$ git show-branch --all
* [master] Initial commit from SVN Repo
 ! [origin/HEAD] Initial commit from SVN Repo
  ! [origin/MC885] Added new columns & fields
   ! [origin/master] Initial commit from SVN Repo
----
  +  [origin/MC6885] Added new columns & fields
*+++ [master] Initial commit from SVN Repo


$ git show-branch --remotes
! [origin/HEAD] Initial commit from SVN Repo
 ! [origin/MC6885] Added new columns & fields
  ! [origin/master] Initial commit from SVN Repo
---
 +  [origin/MC6885] Added new columns & fields
+++ [origin/HEAD] Initial commit from SVN Repo


$ git checkout MC6885
Switched to branch 'MC6885'
Help, Checkout is for switching between branches in a repository you already have. $ git checkout -b MC6886, -b is used to create a new branch if you don't have.


$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 2 and 13 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
Or
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)
Changes to be committed:
        modified:   ….
        modified:  
        modified:   ..
        modified:   ….
Unmerged paths:
  (use "git add <file>..." to mark resolution)


$ git reset --hard
HEAD is now at 2bf2325 Purpose of Creating 2bf2325.

$ git gc
Counting objects: 11562, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8866/8866), done.
Writing objects: 100% (11562/11562), done.
Total 11562 (delta 6669), reused 7519 (delta 2669)

$ git pull
 * [new branch]      MC1692          -> origin/MC1692
 * [new branch]      MC3635-continue -> origin/MC3635-continue
   d7d3a30..ba39b  Raj           -> origin/raj
Updating 10ffef7..4266be2
Fast-forward



Available more commits (12/12) in local master. And in remote master permission denied for direct checkin.
$ git log
$ git reset --hard
$ git reset --hard 34c5fdfsdfsdfsdfsdf4fe51e935aa63e32619cd
$ git pull
$ git push

More
Fetch latest changes git fetch origin/master
Discard any local changes git reset --hard origin/master
Replay latest changes from master git rebase origin/master
Replay your work in progress git rebase origin/work-in-progress
Sync your work in progress with latest master git rebase origin/master