Commit graph

32 commits

Author SHA1 Message Date
Joe Ferris
e5c5ff3ebd Use defaultBranch instead of git_template
Git 2.28 now has a setting to change the default branch for new
repositories. This sets init.defaultBranch to main and removes the HEAD
file from the git template.

The HEAD file will need to be removed from ~/.git_template manually, as
rcup does not remove deleted files.

https://github.blog/2020-07-27-highlights-from-git-2-28/#introducing-init-defaultbranch
2020-08-28 17:34:47 -04:00
Geoff Harcourt
6425042ee1 git: Use zebra for moved line colors
This change uses a git 2.15 feature to change the diff colors for lines
that have been moved rather than added or deleted. It provides a cue to
readers that a line's content has not changed.

Adding this setting in gitconfig should not break earlier git. (Tested
against 2.14 and the change had no effect.)
2018-01-03 16:45:22 -05:00
Sean Doyle
7733711c3b Add git pf alias
Using `--force-with-lease` allows one to force push without the risk of
unintentionally overwriting someone else's work.

The git-push(1) man page states:

> Usually, "git push" refuses to update a remote ref that is not an
> ancestor of the local ref used to overwrite it.
>
> This option overrides this restriction if the current value of the
> remote ref is the expected value. "git push" fails otherwise.
>
> --force-with-lease alone, without specifying the details, will protect
> all remote refs that are going to be updated by requiring their
> current value to be the same as the remote-tracking branch we have for
> them.
>
> --@calleerlandsson
> -- https://github.com/thoughtbot/guides/pull/363
2015-10-16 11:47:58 -04:00
Blaine Schmeisser
f908cc9b8f Update amend to set the current date on the commit. 2015-07-12 13:16:26 -07:00
George Brocklehurst
ed6f00931a
Enable Git's autosquash feature by default.
Autosquash makes it quicker and easier to squash or fixup commits during an
interactive rebase. It can be enabled for each rebase using `git rebase -i
--autosquash`, but it's easier to turn it on by default.

Say I have this history:

    $ git log --oneline
    aaa1111 A first commit
    bbb2222 A second commit
    ccc3333 A third commit

I make another change that I already know should be squashed into "A
second commit". I can do this:

    $ git add .
    $ git commit --squash bbb2222
    [my-branch ddd4444] squash! A second commit

Then when I rebase:

    $ git rebase -i origin/my-branch

The interactive rebase list will be set up ready to squash:

    pick aaa1111 A first commit
    pick bbb2222 A second commit
    squash ddd4444 squash! A second commit
    pick ccc3333 A third commit

Since it's unlikely that anyone will be writing a commit message that begins
`squash!` or `fixup!` when they don't want this behaviour, and the user
still has a chance to review what's going to happen with the rebase, it's
safe to have it always turned on.
2015-05-02 22:37:41 -04:00
Dan Croak
24b34d1bec Move Git aliases to subcommand scripts
Any executable script on you PATH
that is named `git-some-name`
will be available as a git subcommand,
which means you could do `git some-name` to run the script.

Git adds them to `git help -a` under the title
"git commands available from elsewhere on your $PATH",
which will then power the auto completion,
so that will also work for any command you add.

http://blog.zamith.pt/blog/2014/11/05/supercharging-your-git/

Examples of other projects that structure their dotfiles like this:

https://github.com/robbyrussell/oh-my-zsh
https://github.com/tj/git-extras
https://github.com/holman/dotfiles
2015-04-27 13:47:52 -07:00
Blaine Schmeisser
55fca47954 Add the -v flag to commit --amend.
This allows us to always see things we are going to commit, even if we
are amending.
2015-02-23 14:52:02 -06:00
Ian Zabel
bca5bdfd9e Add git branches command
* Lists all remote branches
* Sorts by last commit date, descending
* Shows how long the branch has been around
* Shows last commit author

```
$ git branches
6 days ago  Dan Croak  origin/HEAD
6 days ago  Dan Croak  origin/master
5 months ago  Dan Croak  origin/dc-rbenv-zsh
6 months ago  Sean Doyle  origin/sd-nvm-path
6 months ago  Tute Costa  origin/vim-multiple-cursors
7 months ago  Sean Doyle  origin/sd-vundle
8 months ago  Sean Griffin  origin/sg-disable-spring
9 months ago  Mike Burns  origin/mb-experimental-tag
```
2015-02-20 16:40:12 -05:00
Dan Croak
326fae7de7 Switch from gh to hub
* `hub` is the official GitHub client.
* Like `gh`, `hub` 2.2.0 now powered by the Go programming language.
  https://github.com/github/hub/releases/tag/v2.2.0
* It has been bottled in Homebrew.
  Homebrew/homebrew@1ad37e4
* We are using it in the Laptop script.
  9fe038cd81
2015-02-18 09:59:14 -08:00
Dan Croak
b0fe7c01ff Add git rename-branch alias
* Extract `git current-branch` alias.
* Re-use `git current-branch` in two places.
2015-01-25 16:48:36 -08:00
Ian Zabel
f587e307e8 Revert "include, filter, user"
This reverts commit 383612ac4c.
2014-11-02 11:35:59 -05:00
Ian Zabel
383612ac4c include, filter, user 2014-11-02 11:33:26 -05:00
jake romer
635992e1e9 Include local gitconfig at the end of .gitconfig
Allows for customizing git's commit message template and overriding fetch.prune.
2014-10-18 21:43:16 -07:00
Dan Croak
03dc6172f7 Use gh, not hub
[gh] is a [hub] reimplementation that's much faster and is now the official
Github CLI. It appears that "hub" is [deprecated].

[gh]: https://github.com/jingweno/gh
[hub]: https://github.com/github/hub
[deprecated]: github/hub#475

Matches thoughtbot/laptop:

d9a9dfe09b
2014-09-30 15:43:41 -07:00
Sean Doyle
cbdcbce01d Introduces git_template for init templating
Inspired by http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html

* Make `ctags` executable configurable
* Adds `git ctags`
* Runs `ctag` on `commit` / `branch` / `checkout`
* Extensible via `~/.git_template.local/hooks/{pre,post}-*`
* explain `git_template` under `git` section
2014-08-27 16:43:38 -04:00
Dan Croak
49a4597dc4 Make it easy to checkout GitHub pull requests
This alias makes the following workflow possible:

Look at changes:

    git co-pr 123
    git diff origin/master

Bundle, validate tests are passing:

    bundle
    rake

Rebase interactively, squash, and potentially improve commit messages:

    git rebase -i master

Merge code into master:

    git checkout master
    git merge pr/123 --ff-only

Push:

    git push origin master

Clean up:

    git branch -D pr/123
2014-07-25 19:09:11 -07:00
Joe Ferris
6d0ea824f4 Automatically prune remote branches when fetching
* Removes the need to occasionally run `git remote prune`.
* Remove branches when fetching instead of deleting other branches.

https://trello.com/c/ePlghTll/249-configure-git-to-prune-on-fetch
2014-04-21 10:25:20 -04:00
Mike Burns
11a5504dfe Add a commit message template
Using the `commit.template` setting, read in a commit message template
for each commit. This template is commented out so the commit message
author doesn't need to delete it.

The template serves as a reminder on how to write a better commit
message. The bullets are taken from Caleb's blog post[1]. There is no
_problem_ per se -- we are writing good messages these days -- but it's
handy to be reminded of things to think about. For example, people often
forget to note whether there are any side effects.

This message does not show on `git commit --amend`, only normal `git
commit`.

[1] http://bit.ly/13HWyiy
2013-10-08 09:59:44 +02:00
Dan Croak
b7bc52ec20 Git push to current, not upstream
The primary use case for me is to `git push staging` and `git push
production` from the master branch using our typical git workflow:

https://github.com/thoughtbot/guides/tree/master/protocol#deploy
2013-07-10 23:16:27 -07:00
Greg Lazarev
8e141fed5e Include gitconfig.local file for personal changes
* assumes same directory existance
* allows for easier addition of personal configs
2013-06-28 13:11:08 -07:00
Dan Croak
32e79b642f git up alias and git up -i documentation 2013-06-11 14:53:15 -07:00
Dan Croak
bb757b4a23 Add g pr alias for hub pull-request 2013-04-18 21:44:18 -07:00
Dan Croak
e5a38c353a Remove git br alias
I almost never use `git branch`.
2013-04-14 11:30:48 -07:00
Dan Croak
c04243741f Always merge with ff = only
@jferris:

This has the effect that Git will never implicitly do a merge commit,
including while doing git pull. If I'm unexpectedly out of sync when I
git pull, I get this message:

> fatal: Not possible to fast-forward, aborting.

At that point, I know that I've forgotten to do something in my normal
workflow, and I retrace my steps.

@gylaz:

I like the value of seeing a failure message if a pull (or just merge)
fails due to not being able to get fast-forwarded. Then I can look to
see whose changes went out, that I may have not expected to be there.
2013-04-10 10:17:07 -07:00
Greg Lazarev
31231c812a Use color.ui = auto setting to color git output 2013-04-08 23:32:50 -07:00
Derek Prior
7b76714de0 Change the 'git commit --amend' alias to 'git ca' 2013-03-08 17:17:57 -08:00
Joshua Clayton
68fe4b1d4c Update git's push.default from tracking to upstream
The 'tracking' value has been deprecated in favor of 'upstream'.
2013-02-23 19:08:08 -08:00
Joe Ferris
e35064bcee Revert to default Git log style
* Our current style hides message details
* Default style shows details and one-line versions as appropriate
2013-02-21 10:51:12 -05:00
Greg Lazarev
f243090e1e Add git alias branch as br 2013-02-13 09:36:50 -08:00
Dan Croak
bc2bc89cde Add aliases for most common git commands 2013-01-18 11:36:50 -08:00
Dan Croak
f893537686 Add basic git aliases
* Fast commits.
* Fast rebase of origin into feature branch.
* Fast merge feature branch into master.
* Fast branch creation.
* Fast branch deletion.

Conflicts:

	gitconfig
2012-10-08 20:30:29 -07:00
Dan Croak
fdc8afcd19 adding a global .gitconfig that by default tracks branches (so you can 'git push' from a branch it only pushes to the tracking branch you're in) and also provides a tighter, more colorful git log 2011-10-24 10:30:50 -04:00