Skip to content

Instantly share code, notes, and snippets.

@eduzera
Last active January 23, 2019 12:48
Show Gist options
  • Save eduzera/4cabd176a8d62638ae4ab9b116d1b3e2 to your computer and use it in GitHub Desktop.
Save eduzera/4cabd176a8d62638ae4ab9b116d1b3e2 to your computer and use it in GitHub Desktop.
Roadmap - Git tutorial

Tutorial Git

Initial

  • why git?
  • where to host?
  • what do you need to run?
  • set up your account
    • ssh
    • config name
    • email

Teory

  • Concept of code version
  • Organization of commits
  • Branch
  • source tree
  • pull request

Pratical

  • init repository
  • .gitignore
  • .git/ folder
  • adding files
  • first commit
  • git log
  • create repository
  • add new repository
  • push repository
  • push to new repository
  • merge
  • rebase
  • resolving conflict

Code

init a new repository

git init

setting your name

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

ignoring files

vim .gitignore

 Ignore bundler config.
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*

/node_modules
/yarn-error.log

/public/assets

your first commit

git add .

git commit -am 'first commit'

log of commits

git log

pushing your code to new repository

git remote add <REMOTE_NAME> <REMOTE_ADDRESS>

git push <REMOTE_NAME> master

merging your branch with master

git checkout -b <BRANCH_NAME>

# ...
# make some new code or some file change
# commit your code
# ...

git checkout master

git merge <BRANCH_NAME>

rebasing your branch with master

git checkout -b <BRANCH_NAME>

# ...
# make some new code or some file change
# commit your code
# ...

git checkout master

git rebase <BRANCH_NAME>

resolving conflict with merge

git pull <REMOTE_NAME> <BRANCH_NAME>

# ...
resolve conflict
# ...

git add .
git commit -am "<COMMIT_MESSAGE>"

resolving conflict with rebase

git pull --rebase <REMOTE_NAME> <BRANCH_NAME>

# ...
resolve conflict
# ...

git rebase --continue

discarting some file not commited

git checkout <FILE_NAME>

aboritng rebase

git rebase --abort

reset hard

Be careful, use when it's necessary. it's came back to commit hash and ignore the rest

git reset HARD <COMMIT_HASH>

Back 1 commit

git reset HARD ~1

overhiding repository

git push -f <REMOTE_NAME> <BRANCH_NAME>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment