christianmlong + git   203

Exclude a directory from git diff - Stack Overflow
git diff previous_release..current_release -- . ':!spec'

This is a newish git feature which allows excluding certain paths. It should be more reliable than various shell oneliners.
git  diff  exclude  path 
march 2019 by christianmlong
Git add lines to index by grep/regex - Stack Overflow
# check that the regex search correctly matches the changes you want.
git diff -U0 | grepdiff 'regex search' --output-matching=hunk

# then apply the changes to the index
git diff -U0 | grepdiff 'regex search' --output-matching=hunk | git apply --cached --unidiff-zero
git  regex  line  add  patch 
july 2018 by christianmlong
What's the fastest way to edit hundreds of Git commit messages? - Stack Overflow
git filter-branch --msg-filter 'sed "s/Refs: #xxxxx/Refs: #22917/g"' master..my_branch

And after you do git filter-branch, you can do this to get rid of the leftover head reference

git update-ref -d refs/original/refs/heads/whatever
git  rebase  reword  script  commit  message  edit 
july 2018 by christianmlong
Create an Application from Source Control
Studio can be integrated with a Git repository to manage source control for the application development process. You can use any Git repository that is reachable using an https URL and a user account. Applications can be linked to source control after development has started. In this example, the source code for an application already under development exists in a Git repository. You will create a new app from that source.
servicenow  application  studio  git 
april 2018 by christianmlong
Step-by-step guide on how to create a GPG key on keybase.io, adding it to a local GPG setup and use it with Git and GitHub.
Set up Keybase.io, GPG & Git to sign commits on GitHub

This is a step-by-step guide on how to create a GPG key on keybase.io, adding it to a local GPG setup and use it with Git and GitHub.

Although this guide was written for macOS, most commands should work in other operating systems as well.

Discussion on Hacker News.

Note: If you don't want to use Keybase.io, follow this guide instead. For manually transferring keys to different hosts, check out this answer on Stack Overflow.
pgp  gpg  keybase.io  git  sign  commit 
january 2018 by christianmlong
Good-lookin' diffs. Actually… nah… The best-lookin' diffs. 🎉
diff-so-fancy strives to make your diff's human readable instead of machine readable. This helps improve code quality and help you spot defects faster.
git  diff  plugin  format 
november 2017 by christianmlong
rhubarb.vim: GitHub extension for fugitive.vim
rhubarb.vim

If fugitive.vim is the Git, rhubarb.vim is the Hub. Here's the full list of features:

Enables :Gbrowse from fugitive.vim to open GitHub URLs.

Sets up :Git to use hub if installed rather than git.

In commit messages, GitHub issues, issue URLs, and collaborators can be omni-completed (<C-X><C-O>, see :help compl-omni). This makes inserting those Closes #123 remarks slightly easier than copying and pasting from the browser.
git  vim  fugitive  rhubarb  github  hub  tpope  plugin 
august 2017 by christianmlong
Follow-up to 'GitFlow considered harmful' | End of Line Blog
This paragraph nicely summarizes how I handle git workflow (using my git "float" automation).



---

A nice compromise that was suggested multiple times by various commenters was a hybrid approach. Basically, after you've finished your work on the feature branch (meaning, at the point you would do a --no-ff merge in GitFlow), you first delete the remote branch (if there was any), then rebase your changes on top of develop, simultaneously cleaning up the history (correcting commit messages, squashing some commits into one etc.), and only then do a merge with --no-ff. This way you can have the best of both worlds: nice, almost linear history that you get with rebases and good separation and ease of rollback that merges afford you. I agree that this is a very cool approach; the only thing that bothers me about it is I don't know of any way of enforcing it.
git  merge  process  rebase  fast-forward  workflow  git-flow 
april 2017 by christianmlong
Easily checkout local copies of pull requests from remotes:
[alias]
pr = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
git  pull_request  pr  shell  alias 
september 2016 by christianmlong
revert-a-faulty-merge.txt
In depth explanation from Linus about reverting git merges.
git  revert  merge  reference  linus  gitster  junio  hamano  undo 
august 2016 by christianmlong
Re: [git pull] drm-next
Explanation of how to manage branches and merges with git, from Linus Torvalds.
linus  git  mailing_list  post  branch  merge  strategy 
august 2016 by christianmlong
hub · the command-line wrapper for git
git config --global --add hub.host My_Github_Enterprise_server.com
git  github  hub  ghe  enterprise  utility 
july 2016 by christianmlong
shell - force git status to output color on the terminal (inside a script) - Stack Overflow
To avoid changing your git config, you can do this just for the current command by passing the config variable with -c:

git -c color.status=always status | less -REX

That variable is for the status command only.

If you want the same behaviour for other commands, like diff, show and log, then the variable is color.ui:

git -c color.ui=always diff | less -REX

Note that -c must become before the status or diff argument, and not after.
git  status  color  log  pipe 
may 2016 by christianmlong
command - Git alias with positional parameters - Stack Overflow
[alias]
files = "!f() { git diff --name-status $1^ $1; }; f"
git  alias  shell  function 
march 2016 by christianmlong
If you cherry pick, your branch model is wrong
This is likely usually fine, but for us posed a problem because we actually have commits on the master (release) branch that we don’t want coming back into develop. (The commits are config/build related, not application functionality.)

So, we need another place to branch from, that doesn’t have the latest develop work-in-progress. Basically, what develop looked like when the last release was cut.

E.g. we want the DAG to look like:
1
A --- C ----- F develop
2
|\ |
3
| .. | (last release branch)
4
\ \ /
5
\ B -- E / master (release)
6
\ / /
7
--- D -- hot fix

Where, again, the D is the hot fix (but branched off A instead of B), E is where we merged into master, and F into develop.

This approach has the behavior we were looking for, in that commits made directly on master (release), won’t be in the hot fix branch, since it comes directly from develop.
git  branch  model 
march 2016 by christianmlong
How to handle different instances of index.php in codeigniter with git - Stack Overflow
The easiest solution I found to this is to use a smudge filter on your production environment. For details see the git book. You can use a smudge filter to replace a certain word with something else on checkout.

On my setup I use this filter (you can just add this to the .git/config file on your server):

[filter "htproduction"]
smudge = sed 's/\\$site-mode\\$/$site-mode:production$/'
clean = sed 's/\\$site-mode.*\\$/$site-mode$/'

To activate this filter, add this line to .git/info/attributes (create that file if it doesn’t exist):

index.php filter=htproduction
git  smudge  filter  floating  branch 
march 2016 by christianmlong
A noob question, exiting out of Gdiff · Issue #36 · tpope/vim-fugitive
For the past couple of days I've been immediately switching (manually) to the stage buffer after :Gdiff to see what it would be like. I really like it. I just have to train myself to use do instead of dp to stage changes.

My usual flow now:

:Gdiff
<C-w><C-h> (Switch to stage buffer.)
gg (Go to the top of the file.)
]c (Go to next change.)
do, if I want to stage the change.
Repeat from Step 4 until I get to the bottom of the file.
:wq
If I'm ready to commit, :Gcommit

It feels pretty smooth.
@blueyed
blueyed commented on Mar 15, 2013

@Peeja
you might want to try my "gd" and "gD" mappings then: ",gd" for ":Gdiff" and ",gD" to close the diff (via a function); I have mentioned this above already, but here's a link again: https://github.com/blueyed/dotfiles/blob/master/vimrc#L1067
@Peeja
Peeja commented on Mar 15, 2013

@blueyed How do you write the buffer before closing it?
@blueyed
blueyed commented on Mar 15, 2013

Vim asks me, if I want to write the changes (if there are any).
@yevgenko
yevgenko commented on Apr 13, 2013

I've posed the similar question on SO, ended up with the following mapping:

nnoremap <Leader>gD <c-w>h<c-w>c
vim  git  fugitive  workflow  diff  vimdiff  key  mappings 
march 2016 by christianmlong
git - How to list branches that contain a given commit? - Stack Overflow
git branch --contains <commit>

Only list (local) branches which contain the specified commit.

git branch -r --contains <commit>

Lists remote tracking branches as wel
git  branch  contains  commit  list 
march 2016 by christianmlong
How to escape a whole string in a : command? - Vi and Vim Stack Exchange
Escaping spaces in vim ex commands. Use a slash to escape the space.

:Glog -Sdefine\ monitoring_setup
vim  fugitive  escape  space  glog  git  ex 
march 2016 by christianmlong
git - How do I filter log by folder in SourceTree? - Stack Overflow
How do I filter log by folder in SourceTree?

Click on the File Status segmented control in the top left corner.

Above the Files staged in the index area set the filters to Tree View and Show All. All of your files will appear in the Files in the working tree area.

Select one or more files and/or folders, right click and select Log Selected....
git  log  sourcetree  filter  file 
march 2016 by christianmlong
best workflow when using fugitive? : vim
" fugitive git bindings
nnoremap <space>ga :Git add %:p<CR><CR>
nnoremap <space>gs :Gstatus<CR>
nnoremap <space>gc :Gcommit -v -q<CR>
nnoremap <space>gt :Gcommit -v -q %:p<CR>
nnoremap <space>gd :Gdiff<CR>
nnoremap <space>ge :Gedit<CR>
nnoremap <space>gr :Gread<CR>
nnoremap <space>gw :Gwrite<CR><CR>
nnoremap <space>gl :silent! Glog<CR>:bot copen<CR>
nnoremap <space>gp :Ggrep<Space>
nnoremap <space>gm :Gmove<Space>
nnoremap <space>gb :Git branch<Space>
nnoremap <space>go :Git checkout<Space>
nnoremap <space>gps :Dispatch! git push<CR>
nnoremap <space>gpl :Dispatch! git pull<CR>
git  vim  fugitive  plugin  workflow  diff  vimdiff  key  mappings 
march 2016 by christianmlong
Fugitive.vim - exploring the history of a git repository
Browsing past revisions of a file
Browsing past commits
Searching for text in a commit message
git  vim  fugitive  plugin  vimcast  log  grep 
march 2016 by christianmlong
Git patch
git format-patch
git apply
git  format_patch  apply  patch 
march 2016 by christianmlong
git - How do I "blame" a deleted line - Stack Overflow
If you know the contents of the line, this is an ideal use case for:

git log -S <string> path/to/file

which shows you commits which introduce or remove an instance of that string. There's also the -G<regex> which does the same thing with regular expressions! See man git-log and search for the -G and -S options, or pickaxe (the friendly name for these features) for more information.

Also see the -c and -cc options, to manage how it searches merge commits.



Another possibility is this

git blame --reverse START..END filename

From the manpage:

Walk history forward instead of backward. Instead of showing the revision in which a line appeared, this shows the last revision in which a line has existed. This requires a range of revision like START..END where the path to blame exists in START.
git  blame  delete  line 
january 2016 by christianmlong
bumpversion 0.5.3 : Python Package Index
Version-bump your software with a single command!

A small command line tool to simplify releasing software by updating all version strings in your source code by the correct increment. Also creates commits and tags:

version formats are highly configurable
works without any VCS, but happily reads tag information from and writes commits and tags to Git and Mercurial if available
just handles text files, so it’s not specific to any programming language
python  bump  version  bumpversion  git  tag 
january 2016 by christianmlong
Automated patch minimization for bug origin finding | David R. MacIver
Ok, so you know git bisect? You take a commit history and try to find the commit that introduced a problem.

Imagine you had the problem that git bisect solves but uh you hadn’t been very good about commit discipline and you had a whole bunch of large messy commits, several consecutive ones not in a working state, and it wasn’t really clear what happened where.

Not that I know anyone in that situation of course. This is a purely hypothetical scenario.

Well it turns out there’s a solution to this too, and it’s possibly better than git bisect.
git  bisect  alternative  bug  troubleshooting 
january 2016 by christianmlong
Git: move branch pointer to different commit without checkout - Stack Overflow
Move branch d2 to commit abc1234 without doing a checkout.

git branch -f d2 abc1234

Then you can force push it without checkout

git push origin +d2:d2

Be careful, non-fast-forwards can result in lost commits.
git  branch  move  pointer 
december 2015 by christianmlong
git archive - What does tree-ish mean in Git? - Stack Overflow
----------------------------------------------------------------------
| Commit-ish/Tree-ish | Examples
----------------------------------------------------------------------
| 1. <sha1> | dae86e1950b1277e545cee180551750029cfe735
| 2. <describeOutput> | v1.7.4.2-679-g3bee7fb
| 3. <refname> | master, heads/master, refs/heads/master
| 4. <refname>@{<date>} | master@{yesterday}, HEAD@{5 minutes ago}
| 5. <refname>@{<n>} | master@{1}
| 6. @{<n>} | @{1}
| 7. @{-<n>} | @{-1}
| 8. <refname>@{upstream} | master@{upstream}, @{u}
| 9. <rev>^ | HEAD^, v1.5.1^0
| 10. <rev>~<n> | master~3
| 11. <rev>^{<type>} | v0.99.8^{commit}
| 12. <rev>^{} | v0.99.8^{}
| 13. <rev>^{/<text>} | HEAD^{/fix nasty bug}
| 14. :/<text> | :/fix nasty bug
----------------------------------------------------------------------
| Tree-ish only | Examples
----------------------------------------------------------------------
| 15. <rev>:<path> | HEAD:README, :README, master:./README
----------------------------------------------------------------------
| Tree-ish? | Examples
----------------------------------------------------------------------
| 16. :<n>:<path> | :0:README, :README
----------------------------------------------------------------------

Identifiers #1-14 are all "commit-ish", because they all lead to commits, but because commits also point to directory trees, they all ultimately lead to (sub)directory tree objects, and can therefore also be used as "tree-ish".
git  commit  tree  tree-ish  commit-ish  revision  selection  syntax  upstream 
november 2015 by christianmlong
Git - Revision Selection
Revision Selection

Git allows you to specify specific commits or a range of commits in several ways. They aren’t necessarily obvious but are helpful to know.

Full Hash
Short SHA-1
git show HEAD@{5}
git show master@{yesterday}
git show HEAD^
git show HEAD^^^
git show HEAD~3
git log master..experiment (everything that's in experiment but not in master)
git log experiment --not master (same as above)
git log master...experiment (every commit that is not shared by both branches)
git  reference  revision  hash  selection 
november 2015 by christianmlong
github deploy keys: how Do I authorize more than one repository for a single machine - Stack Overflow
The simplest solution I found was outlined here.

1) Enter this command(You'll do this for however many keys you need):

ssh-keygen -t rsa -C "your_email@example.com"

2) When prompted with the the statement below type in a unique name(i.e.,foo1_rsa).The file will be created in your current directory and you may need to move it to .ssh if you want to be tidy:

Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

3) Update your SSH config file:

vi ~/.ssh/config

Which may be empty:

Host cheech github.com
Hostname github.com
IdentityFile ~/.ssh/foo1_rsa

Host chong github.com
Hostname github.com
IdentityFile ~/.ssh/foo2_rsa
ssh  git  deploy  key  multiple  config 
october 2015 by christianmlong
Using Multiple Github Deploy Keys for a Single User on a Single Linux Server | Snipe.Net
Fortunately, the workaround here is very simple, using named SSH keys and an SSH config file.
ssh  git  deploy  key  multiple  config 
october 2015 by christianmlong
Safely storing passwords and secrets in your git repo
Blackbox is a suite of scripts that aims to marry the ever-warring security and convenience into something that should satisfy both the development and security teams.

Blackbox uses GPG to encrypt files before they're sent to your DVCS (assuming GitHub for the remainder of this article), and decrypts them when needed, either by you, your team, or an automated system
git  secrets  security  encryption  blackbox  howto 
october 2015 by christianmlong
« earlier      
per page:    204080120160

related tags

3.6.5  add  advice  agent  alias  aliases  alternative  amend  and  annoyances  app  application  apply  archive  author  autocrlf  automate  back  bash  bisect  bitbucket  blackbox  blame  blog  book  branch  branches  brew  bug  bump  bumpversion  caret  change  changed  changes  cheatsheet  checkout  cherry-pick  clean  collection  color  commit  commit-ish  compile  completion  config  configuration  conflict  contains  conventions  crisscross  crlf  curses  d3  daemon  default  delete  deploy  deployment  describe  development  diff  difftool  display  does  dotfiles  download  edit  edited  email  emails  encryption  endings  enterprise  escape  etiquette  ex  exclude  explanation  fancy  fast-forward  fastforward  ff-only  file  files  filter  fix  floating  flowchart  force  force-with-lease  forget  fork  forks  format  formatting  format_patch  forth  forwarding  foxtrot  fugitive  function  gc  ghe  git  git-flow  git-info  git-notes  github  github-pages  gitignore  gitster  git_add  git_ssh  global  glog  gpg  graft  graph  grep  guidelines  hack  hamano  hash  heroku  hg  history  homebrew  hooks  howto  hub  hunk  import  info  information  install  interactive  interface  jekyll  junio  kdiff3  keep  key  keybase.io  latest  lie  line  linus  linux  list  local  log  lol  lola  mac  mailing_list  maintain  manpages  mappings  master  mercurial  merge  mergetool  message  messages  migration  model  move  msysgit  multiple  not  notes  octopus  old  one  origin  orphan  ours  pageant  passthrough  patch  path  permissions  pgp  philosophy  pipe  plink  plugin  plus  pointer  post  pr  pre-commit  preserve  process  project  pro_and_con  pull  pull_request  puppet  purge  push  PuTTY  python  r10k  range  rant  rebase  recovery  reference  reflog  refspec  regex  release  remote  remove  rename  replace  repo  repository  request  rerere  reset  reverse  revert  revision  reword  rewrite  rewrite_history  rhubarb  scope  script  scripting  secrets  security  selection  selective  serve  servicenow  setup  shell  show-branch  shrink  sign  simplification  size  smudge  source  sourcetree  space  sparse  spell  spellcheck  split  squash  ssh  ssh_auth_sock  standards  stash  status  strategy  studio  subdirectory  submodule  subtree  sudo  svn  switch  sync  syntax  tag  theirs  tilde  tips  tool  tpope  track  tracking  tree  tree-ish  troubleshooting  tutorial  two  ui  undo  up  upstream  user  utilities  utility  version  vim  vimcast  vimdiff  vimdiff2  vimdiff3  visualization  warning  whitespace  windows  workflow  working  wrapper 

Copy this bookmark:



description:


tags: