Topic #1: Performing common tasks with git

in #nodejs7 years ago

If you followed Topic #1 Git Basics you should have a working environment with git installed and a working repository. If you had trouble setting it up please let me know.


Topics

NTopic
1Getting git basics, create repository, configure globals,
get basic git knowledge in the most common commands.
- Creating a VM
- Topic #1 Git Basics
-Learn BDD development using Cucumber.
-Run tests and verify results
-Setting up NPM for NodeJS dependencies.
-Setting up Sublime text editor with certain plugins and configuration
to suit your programming language needs.
-Start an Express application for web usage.
-Save data in MongoDB
-Get some MongoDB basic usage and queries.
-Apply styles to the web application.
-Deploy application in Heroku.
-Run tests and verify results

For now we will start creating the basic structure of our project. Most of the time the project structure might be there (if you cloned a project or if you are working in an existing one). As we do have an empty repository. Let’s create a 2 important files.

I always like to start a project with these 2 files.

  • README.md file
  • .gitignore

In the readme file we will just stating which is the project goal and basic information about it. We will be improving it as we add more features and capabilities to the project.
Git ignore file helps make development easy and avoid including files in the repository that are not needed for a fresh install or clean set up of our current project.

touch README.md
touch .gitignore

Personal [Running] - Oracle VM VirtualBox_002.png

For now I'll just create the files and push the changes in master

Branching


Branching is usually the way to organize code that is ready for usage or production deployment, code that is being implemented for certain features, code that is being added in order to fix a failure or bug.
For now we have the ‘master’ repository. Think of it as the final release. I like to create a development branch and as many feature branch as we add functionality.

Let’s create out first branch from master.

Tip
Try to get the latest code from the repository. (We are the only developer adding code at the moment) but this changes as more developers get involved in the project.

Lets try to pull every possible change before creating our local branch.
git pull
With that we are getting latest changes that were committed and pushed into the master branch.
We can now create our development branch with the following git command.
git checkout -b dev
I created it like dev but it can be any other name. Both branches should be matched in time at this moment and the same history is shared.

Personal [Running] - Oracle VM VirtualBox_003.png

Great! We have a local branch called dev but is not in the repository yet. We need to push it there. You can just try:
git push
And git will show you the exact command to push a local branch into the remote or origin repository, basically publishing it to the service. Now we have 2 branches that have some history in common but dev has an extra commit. (The one that I added with echo "node_modules" >> .gitignore it just adds that line to the file and will prevent git to upload the node_modules folder and its content, more on this later on)

Personal [Running] - Oracle VM VirtualBox_004.png

Now we can see the differences between the 2 branches in github. New branch was pushed succesfully:

Personal [Running] - Oracle VM VirtualBox_005.png

Now we can see the commits:

Personal [Running] - Oracle VM VirtualBox_006.png
The first 2 were made in master and as we created a new branch from that point the third commit is just in dev branch for now.

You can also check the network graph pretty useful when there are multiple branches and not certainty of how updated they are.
Personal [Running] - Oracle VM VirtualBox_007.png


What have we done so far?

  • Installed a VM for development or set up the development environment.
  • Installed git, created a repository.
  • Learnt some git basics.
  • Created 1 branch for development.
  • Created a .gitignore file (trust me a lot of problems were avoided).

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 64876.28
ETH 2650.41
USDT 1.00
SBD 2.81