GithubHelp home page GithubHelp logo

fantastic-git's Introduction

fantastic-git

Contents

Reading πŸ“”

Repos

  • gitflow Git extensions to provide high-level repository operations for Vincent Driessen's branching model
  • diff-so-fancy Good-lookin' diffs with diff-highlight and more

GitHub

  • twitter-for-github Twitter handles for GitHub
  • octotree Code tree for GitHub and GitLab
  • isometric-contributions Render an isometric pixel art version of your contribution graph in Chrome and Safari.
  • github-s3 Shell scripts that make it really easy to archive and restore repositories between GitHub and AWS S3

Commands

Tag πŸ”’

List all tags

git tag

Tag a commit

git tag -a v1.4 -m "my version 1.4"

Delete remote tags

git push --delete origin tagname
git push origin :tagname

Push tag to remote

git push origin tagname

Rename tag

git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags

Move tag from one commit to another commit

git push origin :refs/tags/<tagname>
git tag -fa tagname
git push origin master --tags

Remote ☁️

List all remote

git remote

Rename remote

git remote rename old new

Branch πŸŽ‹

List all branches

git branch

Create a branch

Create the branch on your local machine and switch in this branch

git checkout -b branch_name

Create branch from commit

git branch branch_name sha1_of_commit

Push the branch to remote

git push origin branch_name

Rename local branch

Rename other branch

git branch -m old new

Rename current branch

git branch -m new

Rename remote branch

git branch -m old new                # Rename branch locally    
git push origin :old                 # Delete the old branch    
git push --set-upstream origin new   # Push the new branch, set local branch to track the new remote

Delete a branch

git branch -D the_local_branch
git push origin :the_remote_branch

Commit ✏️

Undo last commit

git reset --hard HEAD~1

Squash last n commits into one commit

git rebase -i HEAD~5
git reset --soft HEAD~5
git add .
git commit -m "Update"
git push -f origin master

Move last commits into new branch

git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch

Pick

git cherry-pick hash_commit_A hash_commit_B

Reflog

Show reflog

git reflog

Get commit

git reset --hard 0254ea7
git cherry-pick 12944d8

Revert

git revert --no-commit 0766c053..HEAD
git commit

Amend

git commit --amend
git commit --amend --no-edit
git commit --amend -m "New commit message"
git commit --amend -m "New commit message"
git push --force <repository> <branch>

Checkout 🏁

Checkout a tag

git checkout tagname
git checkout -b newbranchname tagname

Checkout a branch

git checkout destination_branch

Use -m if there is merge conflict

git checkout -m master // from feature branch to master

Checkout a commit

git checkout commit_hash
git checkout -b newbranchname HEAD~4
git checkout -b newbranchname commit_hash
git checkout commit_hash file

Stash πŸ“¦

Stash

git stash save "stash name"
git stash

List all stashes

git stash list

Apply a stash

git stash pop
git stash apply
git stash apply stash@{2}

Rebase 🎐

rebase

git rebase base // rebase the current branch onto base

.gitignore 🍯

Untrack

git rm -r --cached .
git add .
git commit -am "Remove ignored files"

Index πŸ“‡

Remove untracked files

git clean

Remove file from index

git reset file

Reset the index to match the most recent commit

git reset

Reset the index and the working directory to match the most recent commit

git reset --hard

Misc πŸ‘»

Conflicting git rebase

git checkout --ours foo/bar.java
git add foo/bar.java

Resolve git merge conflict

theirs

git pull -X theirs
git checkout --theirs path/to/the/conflicted_file.php
git checkout --theirs .
git add .
git checkout branchA
git merge -X theirs branchB

Merge from master into feature branch after push

git checkout feature1
git merge --no-ff master

fantastic-git's People

Contributors

onmyway133 avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.