User Tools

Site Tools


snippets:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
snippets:git [2015/10/13 09:34] allspark_cpsnippets:git [2022/06/28 10:32] (current) allspark
Line 1: Line 1:
-# git push --force+# git 
 + 
 +https://github.com/github/gitignore 
 + 
 +https://sethrobertson.github.io/GitFixUm/fixup.html 
 + 
 +## git push --force
  
 ``` ```
Line 6: Line 12:
 ``` ```
  
-# tree on console+## remove last commit, but keep changes 
 + 
 +``` 
 +git reset HEAD~  
 +``` 
 + 
 +## tree on console
  
 ``` ```
Line 12: Line 24:
 ``` ```
  
 +```bash
 +#!/bin/bash
 +
 +GIT_DIR=/tmp/example/.git
 +WORK_DIR=/tmp/example/
 +
 +BRANCHES=('feature1', 'feature2')
 +
 +set -x
 +
 +for i in "${BRANCHES[@]}"
 +do
 +    git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} checkout ${i}
 +    git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} rebase master
 +    git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} push -f
 +
 +done
 +
 +git --git-dir=${GIT_DIR} --work-tree=${WORK_DIR} checkout master
 +
 +```
 +
 +## ignore changes in tracked file
 +
 +```
 +git update-index --assume-unchanged file
 +```
 +
 +To undo and start tracking again:
 +
 +```
 +git update-index --no-assume-unchanged [<file> ...]
 +```
 +
 +## split directory to new repo
 +
 +```
 +git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME  BRANCH-NAME 
 +```
 +
 +## show staged diff
 +
 +```
 +git diff --cached
 +```
 +
 +## revert part of a commit
 +
 +```
 +git revert -n $bad_commit    # Revert the commit, but don't commit the changes
 +git reset HEAD .             # Unstage the changes
 +git add --patch .            # Add whatever changes you want
 +git commit                   # Commit those changes
 +```
 +
 +## delete remote branch
 +
 +```
 +git push origin --delete feature/login
 +```
snippets/git.1444721683.txt.gz · Last modified: by allspark_cp