Joined February 2013
·

Jupiter St John

Divine Works
Divine Works
·
earth
·
·
·

Posted to use nano from Git Bash on Windows :D over 1 year ago

@manio143 correct you are my good man

Posted to Checkout/Merge previous branch over 1 year ago

Didn't know merge could be used with - as well. Super pro tip thanks Bro!

@twolfson nice addition with a subtree example

Posted to Use tig (text-mode interface for git) over 1 year ago

So awesome! Thanks much

Posted to use nano from Git Bash on Windows :D over 1 year ago

@sadiqsaleem09 It was a typo. I fixed it above please see, it should be path/to/git/share NOT path/to/git/shared . I apologize for the confusion.

Posted to 'git pull' is evil! over 1 year ago

@likeyn don't get too excited yourself bud!

This article was meant for people that just use git pull without really realizing if that's what they really wish to do,

Like @cassianoleal replied above, if you know what you are doing, then by all means git pull to your hearts content.

HOWEVER-- this article is very valid and IS VERY FAR FROM BULLSHIT.

Best to you mate , cheers :)

Made sure you have then first /
Like: /dev/clipboard

It should work on windows bash.

Hmm are you using an administrator account?

You can also use

$ clip < thing to copy
# then to paste
$ clip > file

hmmm pretty savvy buddy. I like this idea. nice tip :)

for windows users you can use

to copy from a file

$ cat file > /dev/clipboard

to paste into a file

$ cat /dev/clipboard > file

or to check the contents of the clipboard

$ cat /dev/clipboard

:) enjoy.

Posted to gist script from command line over 1 year ago

This looks great. I use the gist package in the package manager for sublime text 2 which is also great.

@carleeto of course :D I'm glad you enjoyed bro. I am going to do a mega git alias protip soon with all of my aliases.

@celc wow sorry I read my second comment this morning, I was half asleep copying and pasting on my phone and pasted the wrong snip

I edited my second comment above to be correct now, my apologies.

@celc thanks bro ;) I'm glad you liked it!

Another option is to save the changes in your working tree into a patch like

$ git diff --binary HEAD > tempPatch.diff 
# just use the --binary if git is failing to recognize your binary files it is a noop by default now,
$ git reset --hard

And apply them later with

$ git apply --stat < yourpatch.diff
# to see what changes the patch will introduce then
$ git apply < yourpatch.diff
# the < in git apply is not neccesary but is ok. To skip writing the patch to the working tree add the  --cache which implies the --index flag. --index is the default when none of the options that disables it is in effect.

This option its good sometimes too.

  • You can also just make a patch from the changes in a particular file like so
$ git diff filename > patch.diff
  • also helpful, you can stash the changes in the staging area in chunks by using the -p flag like this
$ git stash -p

it is basically the same interface as git add --patch.

  • git commit also has the --patch flag or -p so that you can commit only certain changes as well. It functions very similarly to --patch or -p for git add and git stash. Like so
$ git commit -p

Nice bro :) I love this feature of git.

Also helpful, you can use just -p instead of --patch like:

$ git add -p

Also, If you want to easily work on the changes in a stash then un-apply the changes that came from the stash to pop it again later, you can use the below:

-Un-applying a Stash

In some use case scenarios you might want to apply stashed changes, do some work, but then un-apply those changes that originally came from the stash.

Git does not provide such a stash unapply command, but it is possible to achieve the effect by simply retrieving the patch associated with a stash and applying it in reverse:

$ git stash show -p stash@{0} | git apply -R
# Again, if you don’t specify a stash, Git assumes the most recent stash:
$ git stash show -p | git apply -R
# You may want to create an alias and effectively add a stash-unapply command to your git. For example:
$ git config --global alias.stash-unapply '!git stash show -p | git apply -R'
$ git stash apply stash@{0}
# if you don't specifya stash number it will use your most recent one
# ALSO use apply to apply your stash if you use stash pop then the stash-unapply alias won't work anymore as that stash is no longer available to show.
$ #... work work work
$ git stash-unapply
  • lastly you can also apply the changes in a stash to a new branch like so:

-Creating a Branch from a Stash

If you stash some work, leave it there for a while, and continue on the branch from which you stashed the work, you may have a problem reapplying the work.

If the apply tries to modify a file that you’ve since modified, you’ll get a merge conflict and will have to try to resolve it.

If you want an easier way to test the stashed changes again, you can run git stash branch, which creates a new branch for you, checks out the commit you were on when you stashed your work, reapplies your work there, and then drops the stash if it applies successfully:

$ git stash branch testchanges
Switched to a new branch "testchanges"
# On branch testchanges
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#      modified:   index.html
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#
#      modified:   lib/simplegit.rb
#
Dropped refs/stash@{0} (f0dfc4d5dc332d1cee34a634182e168c4efc3359)

-This is a nice shortcut to recover stashed work easily and work on it in a new branch.

-The helpful examples above are from git-scm book

I hope this is helpful.

Posted to 'git pull' is evil! over 1 year ago

@markushausammann As the author points out, please read the article again.

A good rule of thumb: rebase from master onto feature branches and merge feature branches back to master.

To stay updated rebase changes from upstream onto master.

What you have to be careful of, is, do NOT rebase the history you have already pushed upstream. That's all.

Only fetch changes from upstream. Then rebase onto master. After that, rebase master onto any branches that you have made.

Just follow this model and make friends with rebase. Have a read @havvg wrote a great article on rebase.

@jussi-kalliokoski I added your insights and referenced you bro thanks ;) see the edit to gitcurrentbranch above.

Currently I am hacking on your gist to see what comes of it. Let's see if we can refactor it at all.

I will reply to the gist in a bit.

This is brilliant! I made it into a little script called srchrep

#!/bin/sh
replace=$1
replacement=$2
ack "$replace" -la --print0 | xargs -0 -n 1 sed -i "s/$replace/$replacement/"

or as a function for your .bashrc or .bashprofile

function srchrpc () { ack "$1" -la --print0 | xargs -0 -n 1 sed -i "s/$1/$2/"; }
  • note I added the -a flag so that it will do the replace on all files. So, if this isn't the behaviour you are looking for, you want take care with this .
  • just save the script version as whatever you feel comfortable with then, make a symlink or put it in ~/bin and then you can call it like
$ srchrep searchText replacementText 
  • any insight is welcome and appreciated.

@wjonthomas :) I agree completely.

I'm glad we could share.

I submitted a request to @coderwall to allow for a syntax color theme choice in protips. I hope that will alleviate some of the janky syntax issues.

Thanks bro this is handy.

here are a couple for you as well, hopefully they are helpful.

  • Show modified files in the last commit (most recent).

note: you have to put them in your git config like they are below.

dl = "!git ll -1"
  • show diff of the most recent commit
dl = "!git ll -1"
  • and, Show full diff of a commit given a revision (commit sha)
dr  = "!f() { git diff "$1"^.."$1"; }; f"

example usage of dr

$ g dr c4965e2  

use whatever commit sha or (treeish in git) you want to compare the current commit against.

the above are from this super post about git aliases

Thanks for your tip bro! I hope mine was of use as well.

I will post all my aliases in a couple of days.

@jussi-kalliokoski Thanks Bro :) glad you liked it.
In which way would git symbolic-ref --short HEAD achieve the same thing? The same as a git rebase -p? I'm interested to hear more.

How so?

If you in put git symbolic-ref --short HEAD into your shell it will just echo out to the current branch you are on.

example:

(cat) $ git symbolic-ref --short HEAD
cat
  • you can see git just tells us that we are on a branch called cat.

  • if we do the same in master

(master)$ git symbolic-ref --short HEAD
master
  • and git tells us we are on master.

How are you using symbolic-ref to recover from an accidentally squashed merge commit?

I thought that if you create a new branch using symbolic-ref it starts a new git history for the new branch that no longer has any connection to the parent repository.

here is a tidbit from git community book

Creating New Empty Branches

Ocasionally, you may want to keep branches in your repository that do not share an ancestor with your normal code. Some examples of this might be generated documentation or something along those lines. If you want to create a new branch head that does not use your current codebase as a parent, you can create an empty branch like this:

git symbolic-ref HEAD refs/heads/newbranch 
rm .git/index 
git clean -fdx 
<do work> 
git add your files 
git commit -m 'Initial commit'

you can also achieve the same effect as using symbolic-ref to create empty branches, in git 1.7.2 + by using git checkout --orphan.

This also creates a root branch, or a branch without previous history.

I would like to know your thoughts on all of the above.

apologies if this bored you to sleep. I wrote this comment with users in mind that might read this thread that are just starting with git.

  • So if you use git symbolic-ref HEAD newbranch it will create a branch called newbranch which is an orphan root branch that no longer shares the same history as the parent repository.

Your thoughts?

@emgiezet I appreciate that thanks bro. I will be writing a series of protips on git. Keep on the lookout.

Posted to mkdircd the child of mkdir and cd over 1 year ago

Yes that's exactly what I said.
Below is quoted from my protip above.

then we pass the same $@ to cd so that it uses the first argument passed to the function as well.

then the $@ tells mkdir to use the first argument passed to the function . In this case the dirName or the filetree that you input to the command mkdircd

Passing a second argument to this alias is not the point of this command.

Thanks for pointing that out though :P

Posted to 'git pull' is evil! over 1 year ago

@richoh I agree completely see my comment above.

Posted to 'git pull' is evil! over 1 year ago

Yes! Finally we can all take a moment for the death of git pull.

I highly recommend using rebase -p to preserve merge commits though.

I have written a protip follow up on this tip

update above

I will write a follow up pro tip and reference yours.

this is fantastic here is the same with min-width , max-width , and min-device-pixel-ratio

@mixin  respond-to($breakpoint, $breakpoint2) {
     @media  only screen and (min-width: $breakpoint + px) and (max-width: $breakpoint2 + px) and (-webkit-min-device-pixel-ratio : 1.5) and (min-device-pixel-ratio : 1.5) {  @content ; }
}

here is another variation using an if statement

$break-small: 320px;
$break-large: 1024px;

 @mixin  respond-to($media) {
   @ if  $media == handhelds {  //i put a space in between the @ and all the variables so the code wouldn't get borked
     @ media  only screen and (max-width: $break-small) {  @content ; }
  }
   @ else  if $media == medium-screens {
     @ media  only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) {  @content ; }
  }
   @ else  if $media == wide-screens {
     @ media  only screen and (min-width: $break-large) {  @content ; }
  }
   @ else  if $media == retina-screens {
     @ media  only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) and (min-device-pixel-ratio: 1.5) and (-webkit-min-device-pixel-ratio: 1.5) {  @content ; }
  }
}

.profile-pic {
  float: left;
  width: 250px;
   @include  respond-to(handhelds) { width: 100% ;}
   @include  respond-to(medium-screens) { width: 125px; }
   @include  respond-to(wide-screens) { float: none; }
   @include  respond-to(retina-screens) {background-image:url()}
}

A new project on github for sass media queries that looks fantastic sass-mediaqueries github page and sass-mediaqueries website they even have a cool demo page

-thanks for the tips bro :P

this kills it bro! I love it. A definite new favorite part of my workflow with Sublime! Thanks :P

Posted to Cache your scripts with localStorage over 1 year ago

Thanks for this! I'm looking forward to trying it out.

@eviweb this is also good. He is using a bare repo as well. I like this method, however, if you're stuck with a jailshell on a shared hosting no sudo no dice if you know what I mean.

@eviweb you are correct both the GITDIR and the GITWORK_TREE are on the same server. I dont know why you would want to have them on different servers?

Each clone of the GIT repo is essentially a remote working tree. So your local repo is a mirror of your remote working tree after you git pull and git push etc.

Posted to Using GIT to manage a website over 1 year ago

Thanks to you as well bro :D
And thank you for the upvote.

I love that more people are using git

Posted to Git Loves the Environment over 1 year ago

@eviweb agreed. This is one reasons I like git so much. I like the fact that more and more people are jumping on the gitwagon.

  • I updated my protip with a link to yours so that people could learn how to configure git to work with a non-bare repo. :)

Thanks bro :)

Posted to Javascript cms over 1 year ago

This looks great! I will be forking shortly. Thanks.

Posted to Bash Prompt Builder over 1 year ago

This looks great bro!

Posted to Using GIT to manage a website over 1 year ago

@eviweb

My working architecture is identical to yours without the .git directory in working tree. The process of pushing and updating is exactly identical to your method.

my local working directory is identical to yours.

The ONLY difference is I am pushing to a bare repo, and you are pushing to a non-bare repo. For this reason it isn't necessary to set receive.denycurrentbranch ignore

So the ONLY difference is in on my server I have my .git directory in a directory outside of my working tree.

You can change a bare repo to a non-bare and vice versa anytime without any adverse affects by changing the config file in your .git directory.

It is possible to have your .git folder outside your working directory with a non-bare repo like you have, see my newest protip.

Posted to Git for Daily Standup over 1 year ago

You can also make a script and call it git-filename and make sure it's on your path, then you call it with git filename from shell. Instead of using the bang.
There is no need for an alias with this method.

Posted to Using GIT to manage a website over 1 year ago

-Somehow I missed the article you linked to.

-The article the exact method I use besides taking advantage of ssh aliases.

I'm confused why you are setting the

$ git config receive.denycurrentbranch ignore

-this command tells git to ignore if it is currently in a non-bare repo to over-ride its default setting to disallow this.

-what command are you using to initialize your remote repo?

$ git init --bare

or just

$ git init

if you initialize with --bare flags then YOU DON'T want to use the

$ git config receive.denycurrentbranch ignore

all you have to at this point if your post-recieve hook is as above, then the very first time you push you must use

$ git push yourremote +master:refs/heads/master

from your local machine.

-the +master:refs/heads/master tells git about the master branch to track. After that, you can push other branches, tags, etc as normal.

then you can

$ git push yourremote

I hope I didn't get confused somewhere along the way. If I understand correctly, there is no .git folder in your website after you push correct?

here is a newer article explaining the same process as your article.

http://mattbanks.me/wordpress-deployments-with-git/

After seeing the date of the article from Abhijit, I think that setting $ git config receive.denycurrentbranch ignore is no longer necessary if you are pushing to a checked out branch of a bare repo for git 1.7+.

It is still required if you are pushing to a non-bare repo as far as I know.

Posted to Using GIT to manage a website over 1 year ago

@eviweb it's not really a big deal until you have many people working on a repo and pushing to the same working tree.

Here is a good article explaining why you shouldn't push to a non bare repo

http://gitready.com/advanced/2009/02/01/push-to-only-bare-repositories.html

I will have some time this afternoon I will make that tip.

this is great thanks bro!

I just use

touch path/to/file

as well but will definitely start to use this a lot.

Posted to Using GIT to manage a website over 1 year ago

this works well but I like working with a bare repo outside my public directory and having the working tree inside my public directory (no .git folder in my website) and then checking the contents of the push to the working tree with a similar hook.

Pro-git advises against pushing directly to a non-bare repo.

I will make a protip with this method in a minute, check my profile if your interested to see how to use a bare repo instead.

Posted to 'cat' with syntax highlighting over 1 year ago

thanks for this!
In order for it to work in bash on Windows I had change it a bit like this.
I changed the alias so I still have the og cat command.

alias ccat='pygmentize -O style=monokai -f terminal -g'

thanks bro.

this looks great. I can't wait to try it out. I often use

sed -i 's#string#otherstring#g' filename

for a replace in a single file.

thanks for the great tip bro.

Posted to Open with Sublime in Windows over 1 year ago

I found this powershell snip, that does the same thing more or less.

 REM Begin Copy
powershell
Set-Content "C:\Program Files\Sublime Text 2\subl.bat" "<a class="_hootified" a="" href="http://twitter.com/#!/@echo" onclick="javascript:var e = document.createEvent("CustomEvent"); e.initCustomEvent("hootletEvent", true, true, {type: "userHandle", value: "@echo"});  document.body.dispatchEvent(e); return false;">@echo</a> off"
Add-Content "C:\Program Files\Sublime Text 2\subl.bat" "start sublime_text.exe %1"
if (!($Env:Path.Contains("Sublime"))) {[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Program Files\Sublime Text 2", "Machine")}
exit
REM End Copy 

you just paste into a cmd shell NOT a powershell.

Posted to Sublime Cheat Sheet over 1 year ago

hmmm .pdf and .docx ?? :( :( :(

to create an alias on Windows for git bash add this alias to your .bashrc

$ alias subl="start sublime_text.exe"

and pro re nata

$ subl .

I just edited my css file without enabling the settings in dev tools and it works fine. What is the purpose of enabling this option?

Posted to Use Sublime Text 2 as Git mergetool over 1 year ago

@jchannon just like @sheerun said you have to make a bash alias for subl on Windows. Then this should work.

Great method. I prefer using a bare repo outside of my public directory that has its working tree inside the pub directory.

This way there is no .git dir there and it tells you in pro git that this is the recommended way.

I made protip about this.

Achievements
1,332 Karma
111,397 Total ProTip Views