- From the command line, use Yeoman to generate a new project > yo webapp
- From the command line, initialize the folder as a new Git repository > git init
- From the command line, open the new project using an Editor of your choice > code .
As you can see, much more is being done from the command line. New tools such as cmder are being used to gain quick access to command windows for Powershell/Node/etc to assist and speed up this flow. Cmder is great because it has transparency, allows you to have multiple tabs, and is easily summoned and hidden away using CTRL+`.
For my task today I decided to initialize a Git repository, add a file, make changes to the file, and commit those files to a Git branch all from the command line. I wanted to use Powershell to create the project folder and the initial file so that I could tick my "One thing per day" goal of using PS for something at least once per day!
I found the New-Item (alias: ni) cmdlet which allows you to create a variety of item types. To create a new folder, give it the -ItemType of 'directory' and then the name of the folder that you wish to create. E.g.
> New-Item -ItemType directory myNewDirectory
I then went ahead and used Git to initialize a repo in the new folder:
> git init
New-Item can also be used to create files, just give it the name of the file that you want to create:
> ni "file1.txt" > notepad "file1.txt"
This adds a new file named file1.txt and opens it in Notepad.
> git add . > git commit -a -m "Adding file1.txt"
This will commit the changes of to your Git repo. It's easy to visualize what's happening in Git Extensions:
The folder can be opened using VS Code using code and a dot "." to open the folder that you are currently in:
> code .
After playing around with Git for a while, I wanted to delete my test folder so I typed Remove- and pressed CTRL-SPACE to find out if Powershell had a Remove-Item command
And sure enough it did. So I finished with the following PS command to blow away my test folder:
> rm "\testdir" -force
What I Learned:
- When using cmder, I can start typing the name of a command and then use CTRL+SPACE to find all matching cmdlets