Tuesday 2 February 2021

Git branches

command local remote
Show all branches git branch -a git branch -r
Branch details git branch -vva git branch -vv
create a new branch & check it out git checkout -b {branchName} -
Create a new branch git branch {branchName} -
Merge branches git merge {branchName} -

Monday 1 February 2021

git show

how to view a previously checked in version of a file!!!

let's start with creating a dummy project


the commands are simple

  • mkdir dummy 
  • cd dummy
  • git init
  • explorer .

the above simply do the following

  • create a folder called dummy
  • enter the dummy folder
  • initialize a git repo 
  • open the folder in explorer 
with your explorer open you should see the secret .git folder


now lets create a file anc commit it to our repo


  • echo 'hello world' > readme.txt
  • git add .
  • git commit -m 'initialized readme file'

the above simply do the following

  • create a file called readme.txt with hello world as the content
  • add it to our git repo
  • commit it to our git repo with a message.
now let's do the same thing again but this time let's change the content of our readme file



the exact same process as above but now the content of readme file went from 

"hello world" to "this is a change"

and for fun let's make one more commit, this time let's change the content of our readme file to "and this is a second change"


so we have now changed our content three times, to see our three commit's type in

git log --pretty=oneline to list our git hash with comment, now normally you can just use git log, but for brevity I prefer the --pretty=online option. This also conveys the value of small well commented commits, but that is a different story.


so at this point you may ask yourself wtf? i just wanted to know how to view a previously checked in version of my file. well buckle up buttercup.




git show ffe1c:readme.txt > original.txt

by using the first five chars of the hash with a path to the file we can pipe that version of the file to our original text file. now you can open that version of the file 



and there you go



all three versions of our readme.