Skip to main content

Git Commands

Cloning a remote repository
$ git clone https://....xyz.git

check history
$ git log

what was the last commit made
$ git show HEAD
$ git show HEAD~1
$ git show

where did the source come from in current git?
$ git remote
origin

whats the remote URL?
$git remote -v

check local branches
$ git branch -r

check remote branches
$ git branch -r

check tags
$ git tag


//TODO add commands to create local repository

whats the remote url for my local repository (will be nothing by default)?
git remote -v

how do I add a remote destination to my repository?
$ git remote add origin https://github.com/bhajanpreets/MyBankBasic.git
(origin is an arbitrary name, I can call it anything)
(you can pull from multiple repositories)
if someone sends a pull request you can add their public repository and pull their changes into your local repository
you can have multiple remotes to evaluate the patches

After adding remote, how do I pull any changes from the remote repository?
$ git fetch
or, if there are multiple remotes I can give the name
$ git fetch origin

now check log to see the difference
$ git log origin/master

to merge code (origin/master is the remote)
$ git merge origin/master

How do I see remote branch that I merged from?
$ git branch -r

Its very common to run
$ git fetch; git merge origin/master

These two steps are combined in git pull
$ git pull

how do I set correspondence between my local branch and remote branch before git pull?
$ git branch --set-upstream master origin/master

or else I can specify correspondence in command itself,
$ git pull origin master

How do I push local changes to remote repository?
$ git status
(to check the local changes)
$ git commit -am
(a is to add file and m is for comment message)
$ git status
(will tell that you need to push)
$ git push
(will ask for user name password)

how do I prevent asking for username and password -- add ssh version of the origin?
$ git remote rm origin
$ git remote -v
$ git remote add origin git@github.com:bhajanpreets/MyBankBasic.git
$ git remote -v
origin  git@github.com/bhajanpreets/MyBankBasic.git (fetch)
origin  git@github.com/bhajanpreets/MyBankBasic.git (push)
$ git push
(need to generate ssh key first - don't have it yet in bhajanpreets so I am using https)

Now how do I add a new tag?
$ git tag v1.2
or
$ git tag -a v1.2 (to add some message)
and push it to remote
$ git tag -s v1.2 (signed tag to confirm that I added this tag and no one else modified it)
$git push --tags (will push tags)



Comments

Popular posts from this blog

JSF-PrimeFaces

JSF basics Web pages can be created in facelets using the standard JSTL We can use templates We can manage resource files like stylesheets, javascripts etc using resource libraries and resource library contracts Facelets is based on xhtml To use JSF with tomcat check the following page: http://stackoverflow.com/documentation/jsf/916/getting-started-with-jsf#t=201704050012362807453 I will use MyFaces here. Will also add maven tomcat plugin ( http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/usage.html ) to run tomcat from maven. Here is the sample project https://github.com/bhajanpreets/JSFBase/tree/v1-jsf-basic/jsf-basic To run I use "clean install tomcat:run" target We use the elements from specific xml namespace with h prefix as seen below... Usually in JSP we declare tag libraries, in JSF we use xml namespaces as done above These are the basic tag libraries in JSF HTML UI components library for various basic html componen...

Simple FitNesse tutorial

(Time spent for writing - 1:30 min) In simple words, FitNesse is a testing framework that can be used to develop automated test cases. I had searched many posts but could not find a single tutorial that could help me get started with FitNesse. So writing it now... BTW I am a java developer, so this tutorial is in pure java! I use windows XP and Java version is 1.5.0 To get started first download FitNesse from http://fitnesse.org/ I didnt like its 2 minute example, because that just showed what it does, doesnt really help me to start with development. They should have a real getting started tutorial there, I think. I had downloaded fitnesse20070619.zip from downloads section After downloading, install it by unzipping the all the files to a some location like c:\fitnesse c:\fitnesse will then act as the root folder for you and all the classpaths will be relative to root folder By default FitNesse will run on port 80. If you want another port you can edit the run.bat file in the root fol...

Hive

Hive What is Transactional Processing? * Small data * recent data * updates data * real time * narrow scope - single data source What is Analytical Processing? * Mostly batch * Mostly old data * Mostly long running * wide scope multiple data source to give a big picture ----------- RDBMS (mostly for transactional) * Single m/c with backup, structured data, usually one source Its hard to do analytics on RDBMS Big Data (mostly for analytical using data warehouse) * distributed data, semi/unstructured, auto replication with fault tolerance, usually different source and different format Not always... * hbase is special db that can be configured for transactional processing even if its on big data * qlikview can be used for analyitial processing even if its running on a single m/c --------- Whats a Data Warehouse? Technology that aggregates data  from one or more sources for analytical processing used by long running jobs, lagged data, large data, multi s...