Skip to content

Instantly share code, notes, and snippets.

@vargheseraphy
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save vargheseraphy/1c69203877bbf8bdcd42 to your computer and use it in GitHub Desktop.

Select an option

Save vargheseraphy/1c69203877bbf8bdcd42 to your computer and use it in GitHub Desktop.
git commands - upstream , remote url, merge branch, console color

Add user name and mail to git repoository

Some commands for the smooth git work flow

git init
  • initialize a git repository
git Log
  • To check the commits.
git log --graph
  • To show the branches in a graphical way
git status
  • To check any files to be committed.
git add .
  • To add the all files(edited/change) to git
git add (path)
  • to add a specific file from all the changed files
git commit -m "message"
  • Commit the files locally
  • message - desired message
git push
  • Push locally committed folder to remote server
  • git pull to give a pull request in remote
git remote add upstream 'url'
  • A{Master} --(fork)--> B{branch} --(pull)--> C{local} <---(fetch upstram)--- A{master}
git fetch upstream
  • to get updates from A{master} directly to lacal
git pull master
  • download the contents from master
git pull upstream master
  • download the all files from upstream master
git config --get remote.upstream.url
  • to check the upsteam url
git config --get remote.origin.url
  • to view master url
git remote set-url origin //http/url/....

to change origin master

git reset HEAD --hard
  • to clear all uncommitted changes in working Head
git init
  • initilise the repository for git operations (commit, revert, add...)
git clone 'url'
  • copy remote repository to local

Basic git commands

git reset 'commit id'
  • reset the files to a particular commit and delete all commits after 'commit id'
git stash
  • move the non- committed changes from repository (which is espessialy added)
git stash --patch
  • to remove unwanted files from git add --all while commiting
  • y- to stash(not add)
  • n - ! stash (add )
git checkout -b branch_name
  • create a branch and continue working in that branch
git branch -D branch_name
  • to delete branch from local repository
  • not possible to delete HEAD branch
git branch branch_name
  • to create a new branch
git branch
  • to show current branch
git checkout master/'branch_name'
  • to switch to required branch or master
git merge branch_name
  • to merge branch to HEAD
  • or merge master to HEAD
git push origin --delete branch-name
  • to remove branch from remote repository
git push origin branch_name --force
  • to update(push) forcefully
  • eg:in case of conflict

color git

  • $ git config color.ui true => specific repositiory
  • $ git config --global color.ui true => For all Repository

Add SHH Key

~/Code $ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/system/.ssh/id_rsa):_
Enter passphrase (empty for no passphrase):_
Enter same passphrase again:_
Your identification has been saved in /home/system_naame/.ssh/id_rsa._
Your public key has been saved in /home/system_name/.ssh/id_rsa.pub._
The key fingerprint is:_
92:05:fb:da:04:94:5d:a2:cb:60:7f:8e:47:32:c3:59 system@system.user.local_

_The key's randomart image is:-
+--[ RSA 2048]----+
|      oo...      |
|     ..+..       |
|    o + E        |
|   . = O         |
|      % S        |
|       &         |
|      o +        |
|       .         |
|                 |
+-----------------+

Copy the public key (/home/system_name/.ssh/id_rsa.pub)._
DO NOT copy or share your private key (/home/system_name/.ssh/id_rsa)._

~/Code $ cat /home/system_name/.ssh/id_rsa.pub

reference

http://git-scm.com/book/commands

https://confluence.atlassian.com/display/STASH/Basic+Git+commands

http://gitref.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment