Basic TOOLS

March 2017, Nejc Zdovc

workshop #1

Agenda

Git

Github

NodeJS

NPM

GIT

COMMANDS

config

init

add

status

commit

log

remote

push

 

pull/fetch

branch

checkout

merge

rebase

DEMO

Git - config

git config --global user.name "Your Name"
git config --global user.email "your_email@domain.com"

Git - INIT

# create a new directory
mkdir hello

# go into the new directory
cd hello

# initialize git for the current directory
git init

Git - ADD

# create a new file
echo 'My first file' > first.txt

# let's start tracking this file
git add first.txt
# stage new and modified files 
git add .

# stage new, modified and deleted files
git add -a

# add all files that have the extension .txt (new, modified and deleted)
git add "*.txt"

Other options

Git - STATUS

# get the current status on the current git branch
git status
# get the current status on the current git branch (short description)
git status -s

Other option

Git - COMMIT

# let's commit our changes to the master branch
git commit -m "Our first commit"
# append commit to the previous commit
git commit --amend

# append commit to the previous commit, but don't edit the message
git commit --amend --no-edit

Other options

Git - LOG

# see which commits are on this branch
git log
# show reference log, useful for reseting to the specific "event"
git reflog

Other option

Git - REMOTE

# let's add a remote repository
git remote add origin https://github.com/XXX/XXX.git
# show all remote repositories (-v is used to display more verbose version)
git remote -v

# remove the remote repository
git remote remove origin

Other options

Git - PUSH

# let's push our first commit to the remote repository on a branch master
git push origin master
# you can set remote tracking branch to the current branch
# and when you push for the next time you can just do a simple `git push`
git push -u origin master

Other option

Git - PULL/fetch

# pull some new commits from our remote branch,
# this will integrate all commits into your current working directory
# you can do a simple `git pull`, if you already set tracking branch 
git pull origin master
# get new data from the remote repository,
# but don't integrate it into our working repository
git fetch origin

Git - BRANCH

# let's create a new branch
git branch new_branch
# show all branches; local and remote
git branch -a

# delete the local branch
git branch -d new_branch

# delete the local and remote branch
git branch -d -f new_branch

# rename the branch from old_branch to new_branch
git branch -M old_branch/new_branch

Other options

Git - CHECKOUT

# let's switch to the new branch
git checkout new_branch
# first create a branch and then switch to the newly created branch
git checkout -b new_branch

Other option

Git - MERGE/REBASE

# let's incorporate changes from new_branch 
# into current branch master (new commit)
# git pull command preform
# git merge automatically
git merge new_branch

# let's incorporate changes from new_branch 
# into current branch master
git rebase new_branch

# you can see the difference between
# them bellow

GITHUB

COMMON TERMS

Repository

Pull request

Squash

Fork

Collaborator

Origin / Upstream

GH - PULL request

GH - SQUASH

GH - FORK

NODEJS

NPM

COMMANDS

init

install

run

outdated

DEMO

NPM - INIT

# create package.json file which is used by NPM
npm init

Other option

# create package.json with default values
npm init -y

NPM - INSTALL

# we will install npm package, but we won't add it to package.json file
npm install

Other options

# shorter version of npm install
npm i

# install package and save it to dependencies
npm install --save

# install package and save it to development dependencies
npm install --save-dev

NPM - RUN/OUTDATED

# run scripts that are defined in package.json
npm run
# see which packages are outdated in your package.json
npm outdated

LET'S PRACTICE

Workshop #1 - Basic tools

By Angular Slovenia

Workshop #1 - Basic tools

  • 814