Skip to content

Instantly share code, notes, and snippets.

@yjose
Created December 17, 2020 16:10
Show Gist options
  • Save yjose/9361f4baa7e6b9bf38a64295d5af057b to your computer and use it in GitHub Desktop.
Save yjose/9361f4baa7e6b9bf38a64295d5af057b to your computer and use it in GitHub Desktop.

Git & Github workshop

Git

Instal Git

Download git for your operating system at: https://git-scm.com/downloads

Download VS Code https://code.visualstudio.com/

Configure Git

Configure user information for all local repositories

# Sets the name you want attached to your commit transactions
$ git config --global user.name "[name]"

# Sets the email you want attached to your commit transactions ( use Github email)
$ git config --global user.email "[email address]"

Create a new project

Create a folder and init Git

# create a folder
$  mkdir  git_workshop
$  cd git_workshop

# init git
$  git init

Add README.md file to your folder.

# you can use VScode to open the folder and create the file
touch README.md

See changes that have been made

git diff

Adding files to commit

git add README.md
#or
git add .

Committing files with commit message, this will stage your changes

git commit -m "initial commit "

Branches

Branches are an important part of working with Git.

Any commits you make will be made on the branch you’re currently “checked out” to.

Use git status to see which branch that is.

Creates a new branch

$ git branch [branch-name]
$ git checkout -b [branch-name]

Switches to the specified branch and updates the working directory

$ git checkout [branch-name]

Combines the specified branch’s history into the current branch. This is usually done in pull requests, but is an important Git operation.

$ git merge [branch]

Deletes the specified branch

$ git branch -d [branch-name]

Show all available branches

git branch -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment