Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Friday, April 26, 2013

Keep your vim plugins up to date

Scenario:
You go and download a plugin from a website but the website says, "Check GitHub for the most uptodate version."
So you get the tarball or the file you need and all is good. If you're okay with this, stop reading. You don't need to know the rest.

Method 1:
cd ~/.vim
mkdir gits
cd gits
git clone https://github.com/user/pluginname.git
ln -s ~/.vim/gits/pluginname/plugin/something.vim ~/.vim/plugin/something.vim
ln -s ~/.vim/gits/pluginname/doc/something.txt ~/.vim/doc/something.txt
ln -s ~/.vim/gits/pluginname/autoload/something.vim ~/.vim/autoload/something.vim
(if it exists -- editorconfig, for example)
Check also for plugin/python folders for your plugins.

Yes, I realize this is a bit more painful than just extract/install, but only slightly.
Now, if you want the latest update from the plugin, you can
cd ~/.vim/gits/pluginname/
git pull

Method 2:

cd ~/.vim
git init
mkdir gits

git submodule add https://github.com/user/pluginname.git gits/pluginname

now do the linking.

This second method allows you to version your changes across the entire .vim folder.

You also can checkout specific branches of the plugin, etc.




Saturday, April 20, 2013

Git make "clean" pull request.

Scenario: You've worked your tail off and *know* you're done with .. whatever you're working on, and can't be bothered to fixup/squash/commits properly to hide your work method to send upstream.

you have the most recent git fetch from upstream and you're ready to do a pull request.

git checkout upstream/master
(you get a warning that you're in headless mode. In this case, great, let's do what it says:)

git checkout -b mybranchforthispullrequest

Now you're basically looking at plain upstream/master.

you can either
git merge mylocalworkingbranch (but this keeps the commit history)

or, if you're *certain* you only want to add/replace files (hopefully, only add)
git checkout mylocalworkingbranch myfileiwanttoadd.ext

git add myfileiwanttoadd.ext

git commit -m "Added myfileiwanttoadd.ext"

and just send the branch to your origin or upstream
git push origin mybranchforthispullrequest

Optionally, go to github and do a pull request from mybranchforthispullrequest.


Friday, January 18, 2013

git branch before pull

Things are going well on your version of production/master and you'd like to pull the latest iteration. Oh, sure, you could tar your setup before doing that in case it breaks, but maybe you're stuck for time and too lazy. That's okay. Really it is. just
git branch before-pull-todaysdate
git pull

PANIC! bad stuff, things crashing, etc... maybe that pull isn't nice.
git checkout before-pull-todaysdate

whew... sanity restored. ... OK, it's off hours and you really want to get back to the latest iteration. Managers aren't on your back and you can fix this.
git checkout master

errors, etc. but at least you're at the latest iteration.

BETTER: don't pull. Just git fetch, then git merge when you're ready.

Monday, January 14, 2013

git branch change oops wrong branch

Specific case:

You're working on a feature but forgot to change branches. This feature is going to corrupt master, it seems, but you haven't committed yet.

alternative to stash,
git branch newbranchname
git checkout newbranchname
git add .
git commit -m "I needed a branch for this before killing master"

if you git checkout master, all these new previously uncommitted changes aren't there (whew) but git checkout newbranchname has the stuff you've been working on.

when you're ready to put them back, just merge back to master.

Blog Archive