Create a new git from remote
make project_dir cd project_dir git remote add origin remote-project-path git pull origin masterSet local upstream to remote branch
git branch --set-upstream master origin/masterMerge without adding "merge branch ... " message to log
git pull --rebase origin masterMerge without modifying log
git add . git commit -m 'push to stash' git pull --rebase origin master (fix rebase conflict) git reset HEAD~1Rewind file state to last commit (changes are discarded, dangerous)
git checkout -- file-to-rewindUnstate file changes and keep changes
git reset HEAD file-to-unstageUndo last N commits
git reset --soft HEAD~N # keep changes git reset --hard HEAD~N # discard changes (dangerous)Modify the commit log. See here for details.
git rebase --interactive hash-of-the-parent-commit git push --force # may cause issues if remote changes are pulledGenerate a changelog from git log
# list representation git log --no-merges --pretty=format:' - %s' # graphical representation git log --graph --pretty=format:'%s - %Cred%h%Creset %Cgreen(%cr)%Creset %an' --abbrev-commit --date=relativeMaintain a sub-repository using the subtree merging strategy: see this script.
usage: ./subtree ACTION (ARGS...) Actions Arguments ------- ----------------------------------------------- init (root_git) create subtree-name subtree-dir subtree-git (subtree-branch) update subtree-name subtree-dir push subtree-nameCreate a new branch with clean history
git checkout --orphan new-branch git rm -rf .Force pull and overwrite local files:
git fetch --all git reset --hard origin/master git pull origin master
Resources
http://blog.wu-boy.com/tag/git/A successful Git branching model
No comments:
Post a Comment