Logo
BEAUTY IN SIMPLE

Digital Garden

A collection of short solutions to daily tech problems, notes, some thoughts and explorations that might convert into a blog post someday. My take on Learn in public concept.

title: "Git"

Git

  1. Merge dev branch into master
  2. Create one repository with folders of different projects
  3. Change commit message of the last commit
  4. Checkout pull requests locally
  5. Tags
  6. Log

Merge dev branch into master

  • On dev branch

    git merge master
    - to solve merge conflicts if any
  • Checkout to master branch

git checkout master
  • Merge dev branch into master branch
git merge --no-ff dev
  • Push master branch
git push origin master
  • Delete merged branch
git branch -d dev
  • Delete merged branch on remote host
git push origin :dev

Create one repository with folders of different projects

  1. Create github repository with readme file

  2. Clone it

    git clone <repo_url>
  3. Unzip cloned folder

  4. Copy folder with project into this folder

  5. From root folder add all files to git

    git add .
  6. Commit changes

    git commit -m “message”
  7. Push changes

    git push origin master

To add another folder repeat from 4th step.


Change commit message of the last commit

git commit --amend -m "your new message"

Checkout pull requests locally

  1. git fetch origin pull/ID/head:BRANCHNAME

where

  • ID - pull request's ID (#18)
  • BRANCHNAME - a name of the branch
  1. git checkout BRANCHNAME

For there, you can run the code locally, make changes, then push the new branch up.

Docs


Tags

  • list all your tags
git tag
  • delete tag
git tag -d <tag_name>
  • create tag
git tag <tag_name>
  • push tags
git push origin --tags

Docs


Nice Git Log

git log --graph --oneline --decorate