-
Notifications
You must be signed in to change notification settings - Fork 1
Very Common and Very Uncommon Git Workflows
Kenneth Kasajian edited this page Jan 27, 2017
·
16 revisions
This page assumes the reader is an experienced user of git.
git init
git status -uall
git difftool -d
git add -A
git commit -m "Stuff I just did comment"
git log --oneline --date-order --graph --d -10
git difftool -d --cached
git commit --amend
git reset --soft HEAD^
git remote add origin <url-to-remote>
git push -u origin master
https://github.com/<username>/<repository name>.git
git clean -xfd
git checkout master
git merge --squash bugfix
git commit
######This will take all the commits from the bugfix branch, squash them into one commit and then merge it with your master branch. ######If you want to keep references to the old commit messages you can write git commit (without -m param) and you will get to modify a drafted commit message containing all commit messages that you squashed
git init --separate-git-dir ./git
git push --all origin -u
I'm on a private branch. master is behind origin. I want to switch to master and pull latest but for performance reasons, I don't want the working directory to switch to a stale master only to be immediately replaced with what's on origin.
git fetch
git checkout -B master origin/master
I'm on master, and I want to squash all of my local commits since origin into a single commit before doing a push.
git rebase -i origin/master
git reflog
or
git fsck --lost-found
git push origin origin/<old_name>:refs/heads/<new_name> :<old_name>
git log -p --grep "nasty bug"
git log -p -S 'Date.new'
git log -S 'populate_database' --all
git push -u origin <branch_to_publish>
git push origin :<branch_to_publish>
or
git push origin --delete <branch_to_publish>
git branch --contains <commit>
or
git reflow show --all | grep <commit>
#####Try the animated workflows at:
######The stages of a file in Git
Untracked
'add' --> Unmodified
'edit' --> Modified
'stage' --> Staged
'commit' --> Unmodified
'remove' --> Untracked