Didn't know merge could be used with - as well. Super pro tip thanks Bro!
@twolfson nice addition with a subtree example
So awesome! Thanks much
@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.
@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.
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.
@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 am interested how you are using
symbolic-ref
? I am always eager to know more about git.
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 callednewbranch
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.
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
@richoh I agree completely see my comment above.
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
- coderwall keeps botching my code so i put a space between the
@
variable here is a gist of the same thing
$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()}
}
- the above looks janky so here is a gist of the same thing this second one is from The Sass Way
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
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.
Thanks to you as well bro :D
And thank you for the upvote.
I love that more people are using git
@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 anon-bare
repo. :)
Thanks bro :)
This looks great! I will be forking shortly. Thanks.
This looks great bro!
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.
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.
-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.
@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 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.
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.
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.
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 .
@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.
@manio143 correct you are my good man