Not necessarily. This depends on what branch you're on as well as whether or not it's up to date with the remote.
Lesser known Git commands
21–30 of 142 posts
Re: Lesser known Git commands
#22My most useful bash alias (when you go back to master and want to start at the most up to date everything before creating a new branch): alias grm="git fetch origin && git reset --hard origin/master"
resync = !git reset --hard HEAD && git checkout master && git reset --hard origin/master && git pull
or with a parameter to do the same with any branch:
resync = "!f() { git reset --hard HEAD && git checkout $1 && git reset --hard @{u} && git pull ; }; f"
Re: Lesser known Git commands
#23Re: Lesser known Git commands
#24stp = !git stash && git pull && git stash pop
Re: Lesser known Git commands
#25Warning: not actually git commands, rather TFAA's aliases for possibly useful combinations of switches and/or commands.
Re: Lesser known Git commands
#26I've seen more stash accidents than any other kind with git. Stashing is more dangerous than committing or branching, and to me it doesn't seem to provide any advantages... do people actually find stashing easier than branching? Is it just because when you branch you have to name it, and that causes friction? I stay away from stash. Right from the man page: "If you mistakenly drop or clear stashes, they cannot be rec…
I use stash when I forget to branch. So I might be working and then realize I never branched. So I stash my changes, create a new branch, and then pop my changes on the new branch.
There's nothing wrong with your workflow, btw, stash works in that case, as long as you immediately pop & don't get interrupted by lunch or a phone call.
Stashing is obviously providing some value that people like, it's very popular. But considering that it has extra danger, and that it's really easy to work without stash, I'm still confused why it's so popular.
And fwiw, most of the stash accidents I've seen are fairly simple scenarios like you described, and some teeny tiny twist or interruption causes someone to get confused and lose their stash, or think they lost their stash, and panic.
Re: Lesser known Git commands
#27I've seen more stash accidents than any other kind with git. Stashing is more dangerous than committing or branching, and to me it doesn't seem to provide any advantages... do people actually find stashing easier than branching? Is it just because when you branch you have to name it, and that causes friction? I stay away from stash. Right from the man page: "If you mistakenly drop or clear stashes, they cannot be rec…
I use stash when I forget to branch. So I might be working and then realize I never branched. So I stash my changes, create a new branch, and then pop my changes on the new branch.
Re: Lesser known Git commands
#28> so it’s good practice to create an empty commit as your repository root While I'm aware of issues with rebasing the root commit, I've never heard this advice before and it seems unnecessary.
http://stackoverflow.com/questions/30277149/how-to-use-inter... goes into more detail.
Re: Lesser known Git commands
#29> so it’s good practice to create an empty commit as your repository root While I'm aware of issues with rebasing the root commit, I've never heard this advice before and it seems unnecessary.
Re: Lesser known Git commands
#30My personal favorite two: jschroeder@omniscience:~$ git config alias.up pull --rebase jschroeder@omniscience:~$ git config alias.down push They can be used thusly: git up && git down
void:~% git config alias.funky
! git up && git submodule update
And speaking of lesser known commands, I've been using 'git worktree' recently at work and I'm a big fan. Admittedly, it's probably mostly unknown because it's a new feature.It's a little rough around the edges, but it has made things like customer support context switching much easier since I can leave my current development tree alone and just create a new worktree for the current escalation.