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} | - |
Tuesday 2 February 2021
Git branches
Labels:
git
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
- 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
"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"
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.
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
Labels:
git
Subscribe to:
Posts (Atom)