Live data from Hacker News

Lesser known Git commands

hackernoon.com

11–20 of 142 posts

Re: Lesser known Git commands

#11
post #8

Didn't know about those stash options. I've always used 'git stash save -u' to bring along the untracked files in the stash, that's the more common scenario.

I just usually do something silly like 'git add . && git stash', i had no idea it was built in...

Re: Lesser known Git commands

#12
My 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"

Re: Lesser known Git commands

#13
post #6

My 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

While these aliases are useful, I'm confused why "down" means "push".

Re: Lesser known Git commands

#16
I'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 recovered through the normal safety mechanisms."

https://git-scm.com/docs/git-stash

--

I do like shorty. My version:

  alias gits='git status -sb'
--

My next fave is rebase the current branch against it's upstream branch point:

  [alias]
    rearrange = "!git rebase -i $(git merge-base HEAD @{u})"
git rearrange ftw.

Re: Lesser known Git commands

#17
post #16

I'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

#19
post #6

My 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

While these aliases are useful, I'm confused why "down" means "push".

Well, if you think of yourself of the ruler of the repo and "pushing down" to the plebs, it makes sense ;)

Re: Lesser known Git commands

#20
post #6

My 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

"Here let me UPload the local repo to our git server" git down

"Great now let me DOWNload the changes to another branch" git up

What?

Post reply on HN