Mostrando entradas con la etiqueta git. Mostrar todas las entradas
Mostrando entradas con la etiqueta git. Mostrar todas las entradas

25 de febrero de 2016

$ git lola



Source (and full credits to): http://blog.kfish.org/2010/04/git-lola.html
The best tip I learned at Scott Chacon's talk at linux.conf.au 2010, Git Wrangling - Advanced Tips and Tricks was this alias:
        lol = log --graph --decorate --pretty=oneline --abbrev-commit
This provides a really nice graph of your tree, showing the branch structure of merges etc. Of course there are really nice GUI tools for showing such graphs, but the advantage of git lol is that it works on a console or over ssh, so it is useful for remote development, or native development on an embedded board.
It is even nicer when you turn syntax coloring on in git, which also has the advantage of colorizing diff output to warn about bad whitespace.
To get an idea of a whole project structure, I found myself often running git lol --all, where the --all option says to show all branches. I used that often enough that I made a new alias, git lola:
        lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
which has the added bonus of making me hum Lola every single day.
So, just copy the following into ~/.gitconfig for your full color git lola action:
[alias]
        lol = log --graph --decorate --pretty=oneline --abbrev-commit
        lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
[color]
        branch = auto
        diff = auto
        interactive = auto
        status = auto

19 de febrero de 2016

From the ground up with GIT


A continuación el contenido, materiales y otras yerbas de la Tech Meetup "From the ground up with GIT", que di en el Tech Pub de Santex America, en febrero de 2016:

Link al evento: http://www.meetup.com/Tech-Meetup-Santex-Cordoba-Argentina/events/228759107/

Link a las slides: link

Link a las notas:

Link al video de la charla: link

Link a las scripts para generar conflictos: link

Graciasmiles a todos/as los/as asistentes por venir y por la tan activa participación, que volvió la charla en algo mucho más divertido y enriquecedor (al menos para mi :) ).


¡Salud!

4 de agosto de 2015

Pimp my GIT: Improving GIT command line (cli) interface and usage

Aloha!


Following up yesterday's post, here goes another set of tricks I have done to my GIT setup.

To begin with, add this code to yhe .git/config file of your git repo clone:



Once you do that, you'll see things like colors when running a "git status":




You'lll also be able to use git command shortcuts, like:

- "git st" instead of "git status"
- "git ci" instead of "git commit"
(etc!)


Logs will look much more sexy and colorful.

You'll see diffs with colors and with a much more user-friendly format:





When running "git branch", you'll see the current branch highlighted and the local branches clearly marked in yellow:



And remote branches in green:




That's all for today, folks!


Cheers!

16 de octubre de 2014

How to undo a git rebase / squash / fixup? (a.k.a. "we all poop it sometimes")



Today I had a bit of a mess in one of my PRs by doing an interactive rebase (git rebase -i HEAD~) and a fixup / squash.

Now: What to do now, after doing the wrong squash?

Good news: virtually everything can be undone in GIT :)

"git reflog" was what I was looking for to put thing where they were before:

$ git reflog

At this point you'll see a long list of commits like this one:

 $ git reflog
e074e05 HEAD@{0}: rebase: aborting
b3885fe HEAD@{1}: rebase -i (start): checkout HEAD~7
e074e05 HEAD@{2}: pull origin master: Merge made by the 'recursive' strategy.
b3885fe HEAD@{3}: rebase -i (finish): returning to refs/heads/ticket
b3885fe HEAD@{4}: rebase -i (pick): something
....

Then you need to pick the action you want to go back to and reset to it with this command:

$ git reset --hard HEAD@{N}

Where "N" is the number between curly braces from the list of commits displayed by git reflog.

Et voilà!

26 de marzo de 2014

Create a global GIT hook to check Flake8 before each commit

First, let's install Flake8:




Note It is important to set the right version when installing Flake8, as there there are some versions that are bugged and will prevent the GIT hook to work (like the 2.1.0 version).

Now, let's setup global git commit hooks:

1. Enable git templates:



This tells git to copy everything in ~/.git-templates to your per-project .git/ directory when you run git init

2. Create a directory to hold the global hooks:



3. Write your hooks in ~/.git-templates/hooks.

For example, here's a post-commit hook (located in ~/.git-templates/hooks/post-commit):



4. Make sure the hook is executable.



5. Re-initialize git in each existing repo you'd like to use this in:




NOTE if you already have a hook defined in your local git repo, this will not overwrite it.

Now, let's create a global git pre-commit hook:


Finally, let's take it for a spin!

Go to some of your repos and re-initialize it to take the pre-commit hook:


Now edit some of your Python files, introducing some violation (like a >80 columns line, only one blank line between function/class definitions, etc.) and try to commit it:


Voilà!



27 de noviembre de 2013

How to setup you repo GIT and local instance (like for GitLab) and not to fall in despair

How to setup you repo GIT and local instance (like for GitLab) and not to fall in despair

For a while now, while collaborating with several projects, I noticed that having issues to generated and setup the public keys and configuring the access to GIT repositories was giving a bit of a harsh time to lots of people.

And when in comes to recurring problems there’s nothing better suited than a little reference tutorial to blaze the trail. So, let’s get to it!

#1: generate your SSH key-pair and set it up


Step #1: Check if you don’t already have a key pair


Open a terminal and run the following command:

1
2
3
cd ~/.ssh
ls
# Lists the files in your .ssh directory



Check the directory listing to see if you have a file named either id_rsa.pub or id_dsa.pub. If you don't have either of those files go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.

Step #2: Generate new SSH keys

To generate a new SSH key, enter the code below in the terminal. We want the default settings so when asked to enter a file in which to save the key, just press enter.

1
2
3
4
5
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
ssh-add id_rsa





Now you need to enter a passphrase.

1
2
Enter passphrase (empty for no passphrase): [Type a passphrase]# Enter same passphrase again: [Type passphrase again]



Which should give you something like this:

1
2
3
4
Your identification has been saved in /Users/you/.ssh/id_rsa.# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com



Step #3: Add your SSH key to GitLab

  1. Go to your account settings:
  1. Now go to the SSH keys section:

  1. Click “Add SSH key”
  1. Give it a title you like (in the “Title” field) and paste your public key in the bigger “Key” field:
  1. Click “Add key” and we are done with loading the SSH public key in GitLab!

Step #4: Check everything worked

Now we should have the key pair generated and set up locally and the public key loaded in GitLab. Let’s now make sure this is the case and that everything went fine.

To achieve such a certainty, run the following command:

1
$ ssh -T git@git.santexgroup.com




If everything went well, you should see an output like this:

1
2
$ ssh -T git@git.santexgroup.com
Welcome to GitLab, !




#2: Some extra hints

Now we have the keys and our GitLab repo set up and ready to work. Now you should be able to clone, push/pull and do all sorts of thing with your GIT repos without being prompted for your username and password. If GIT, after making a command, asks you for your username or password, it means something at some point went wrong.

Go back and make sure you didn’t miss any steps or ask someone for help.

Done with this and want to learn some new tricks? Take a look at this link!

Hope this saves you of annoyances and frustrations in the future!

5 de noviembre de 2013

List merge conflicts with GIT


Made a merge, particularly, a big one and you want to know which where the files that had conflicts?

Then, this command might come handy:



You can also make a GIT alias this way:



and then use it like this:

24 de septiembre de 2013

Where to start to learn GIT

Many times I was asked: Where to start to learn GIT?

It is not usual to have a good answer to questions like this in the area of software engineering.

But when it comes to the case of GIT, there is one. This is a great place to start: http://try.github.io/

This is the official GitHub "Got 15 minutes and want to learn Git?" Git tutorial.

Pimp my GIT: mejorando la interfaz para el uso de GIT

Siguiendo con el post de ayer, acá les comparto otras cosas del setup que tengo para git.

El setup este, y va dentro del .git/config de su clone git:


Con esto seteado, verán, por ejemplo, los git status con colores:




Podrán usar abreviaciones de los comandos, como:

- "git st" en vez de "git status"
- "git ci" en vez de "git commit"

Podrán ver un log más interesante y con colores con git log.

Verán los diff coloreados y con formato piola:



Git branch muestra coloreado el branch actual (los branches locales aparecen en amarillo):



Y los branches remotos aparecen en verde:

Inline image 4


Saludos!

23 de septiembre de 2013

Mostrar el branch de GIT y el status actual en el shell prompt y más!

Algunos trucos para configurar nuestro setup local de GIT:

Hace algunos años encontré algo como eso y, con el tiempo, armé una serie de scripts (algunas cosas que hice yo, algunas cosas que fui encontrando en la web), que hacen varias cosas con bash, que están piolas.

¿Qué cosas?

- que se detecte automáticamente si se está en una carpeta perteneciente a un repo git, y que, en el caso que sí lo sea, el prompt muestre información relevante del repo en que se está: branch y estado. Ejemplo:



en ese caso, estoy en el branch "master" y tengo archivos modificados (por eso la "m") y archivos que borré (por eso la "d").

- otra cosa muy piola es tener tab completion (que al apretar tab, con un comando a medio escribir, se muestren opciones para completar ese comando -o que se completen, si hubiera una opción posible). Imaginen eso aplicado a nombres de branch, comandos git y comandos de django (como "python manage.py runserver", por ejemplo).

- Algunas cosas más, como:
-- aumentar el tamaño del history de bash, pero eliminando duplicados, para que al hacer "ctrl r" en la consola, podamos buscar en el historial de los comandos que hicimos y encontrar resultados interesantes.
-- Una larga lista de colores definidos, para directamente poder usarlos en la definición del prompt.

Etc!

Les paso adjuntas las scripts para hacer todo esto:


Las dos primeras las ponen derecho en el home. El .profile pueden ponerlo derecho en el home (si usan Mac y no tienen otro .profile armado) o copiar su contenido a su .profile existente. Si usan Linux, pueden hacer esto mismo con el archivo .bashrc.
(notar que tienen un underscore los archivos, a propósito, para que no sobreescriban cosas sin querer y para que no los tome el file browser como archivos ocultos).


Un abrazo y may the bash be with you (?),


Find out when a line was introduced or deleted in GIT history

Hi!

Did you ever come across a line of code that you d *really* like to know when was introduced/deleted ?

Well, if you are using GIT for your project this might come handy.

Let's say the piece of text you are investigating is this:

a = get_something(some_var)

and it is located in the file some_folder/some_file.py

Then, try this command:

git log -S "a = get_something(some_var)" some_folder/some_file.py

Then, GIT will look for the string we specified string within the commit history and output something like this:

commit
Author: Some Dude <
some.dude@mail.com>
Date:   Fri Feb 15 14:09:18 2013 -0300
    The commit message of this commit.

This came quite handy to me recently. Hope it helps!

1 de octubre de 2012

Working on django-notification (django 1.4 support, internationalization, etc.).

What's this all about?


Working on a Django project, I happened to come across with the need of a notifications app for Django. The first one to take a look at and perhaps the most popular the last years is django-notification. So, let's take a look at it, my friend.

What was the problem?


Well, to begin with, it does not work with Django  1.4 or above. That's the starting point for me to branch out from the original repo of the project. I tuned it up to work with Django 1.4.

Later down the road, we decided to use internationalized dates. And then again, django-notification did not handle them properly (does not suppor internationalization at all). And therefore a zillion of our tests started to throw warning.

Once again, I had some time to spare, and got myself hands on that.

Summarizing

Which changes did I make to django-notification? Let's take a look:

  • Made it work with django 1.4
  • [this is a big one] Made django-notification timezone aware and compliant.
  • Made every single file PEP8 compliant
  • Fixed a bunch of issues I found while going through the codebase (like missing imports)
  • Quite a few code improvements (like the usage of "zip" or "file" as variable names)

Where's this code? How I install it for my project?


The code is available here, at my github account: https://github.com/matiasherranz/django-notification

You can install it with pip this way:

pip install  -e git+https://github.com/matiasherranz/django-notification.git#egg=django-notification

I'm open to suggestions, comments or pull requests to improve the app.

Hope it helps!

10 de noviembre de 2011

A successful Git branching model

Both at work and for my personal software-development-related projects I've been using this excellent branching model suggested by Vincent Driessen in his website: http://nvie.com/posts/a-successful-git-branching-model/

Here's an echo of his awesome post:

 

A successful Git branching model

In this post I present the development model that I’ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I’ve been meaning to write about it for a while now, but I’ve never really found the time to do so thoroughly, until now. I won’t talk about any of the projects’ details, merely about the branching strategy and release management.

It focuses around Git as the tool for the versioning of all of our source code.

Why git?

For a thorough discussion on the pros and cons of Git compared to centralized source code control systems, see the web. There are plenty of flame wars going on there. As a developer, I prefer Git above all other tools around today. Git really changed the way developers think of merging and branching. From the classic CVS/Subversion world I came from, merging/branching has always been considered a bit scary (“beware of merge conflicts, they bite you!”) and something you only do every once in a while.
But with Git, these actions are extremely cheap and simple, and they are considered one of the core parts of your daily workflow, really. For example, in CVS/Subversion books, branching and merging is first discussed in the later chapters (for advanced users), while in every Git book, it’s already covered in chapter 3 (basics).
As a consequence of its simplicity and repetitive nature, branching and merging are no longer something to be afraid of. Version control tools are supposed to assist in branching/merging more than anything else.
Enough about the tools, let’s head onto the development model. The model that I’m going to present here is essentially no more than a set of procedures that every team member has to follow in order to come to a managed software development process.

Decentralized but centralized

The repository setup that we use and that works well with this branching model, is that with a central “truth” repo. Note that this repo is only considered to be the central one (since Git is a DVCS, there is no such thing as a central repo at a technical level). We will refer to this repo as origin, since this name is familiar to all Git users.





Each developer pulls and pushes to origin. But besides the centralized push-pull relationships, each developer may also pull changes from other peers to form sub teams. For example, this might be useful to work together with two or more developers on a big new feature, before pushing the work in progress to origin prematurely. In the figure above, there are subteams of Alice and Bob, Alice and David, and Clair and David.
Technically, this means nothing more than that Alice has defined a Git remote, named bob, pointing to Bob’s repository, and vice versa.

The main branches



At the core, the development model is greatly inspired by existing models out there. The central repo holds two main branches with an infinite lifetime:
  • master
  • develop
The master branch at origin should be familiar to every Git user. Parallel to the master branch, another branch exists called develop.
We consider origin/master to be the main branch where the source code of HEAD always reflects a production-ready state.
We consider origin/develop to be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. Some would call this the “integration branch”. This is where any automatic nightly builds are built from.
When the source code in the develop branch reaches a stable point and is ready to be released, all of the changes should be merged back into master somehow and then tagged with a release number. How this is done in detail will be discussed further on.
Therefore, each time when changes are merged back into master, this is a new production release by definition. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers everytime there was a commit on master.

Supporting branches

Next to the main branches master and develop, our development model uses a variety of supporting branches to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually.
The different types of branches we may use are:
  • Feature branches
  • Release branches
  • Hotfix branches
Each of these branches have a specific purpose and are bound to strict rules as to which branches may be their originating branch and which branches must be their merge targets. We will walk through them in a minute.
By no means are these branches “special” from a technical perspective. The branch types are categorized by how we use them. They are of course plain old Git branches.

Feature branches


May branch off from: develop
Must merge back into: develop
Branch naming convention: anything except master, develop, release-*, or hotfix-*
Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into develop (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).
Feature branches typically exist in developer repos only, not in origin.

Creating a feature branch

When starting work on a new feature, branch off from the develop branch.

$ git checkout -b myfeature develop
Switched to a new branch "myfeature"

Incorporating a finished feature on develop

Finished features may be merged into the develop branch definitely add them to the upcoming release:

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).
$ git push origin develop
 
The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. Compare:

In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the --no-ff flag was used.
Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost.
Unfortunately, I have not found a way to make --no-ff the default behaviour of git merge yet, but it really should be.

Release branches

May branch off from: develop
Must merge back into: develop and master
Branch naming convention: release-*
Release branches support preparation of a new production release. They allow for last-minute dotting of i’s and crossing t’s. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (version number, build dates, etc.). By doing all of this work on a release branch, the develop branch is cleared to receive features for the next big release.
The key moment to branch off a new release branch from develop is when develop (almost) reflects the desired state of the new release. At least all features that are targeted for the release-to-be-built must be merged in to develop at this point in time. All features targeted at future releases may not—they must wait until after the release branch is branched off.
It is exactly at the start of a release branch that the upcoming release gets assigned a version number—not any earlier. Up until that moment, the develop branch reflected changes for the “next release”, but it is unclear whether that “next release” will eventually become 0.3 or 1.0, until the release branch is started. That decision is made on the start of the release branch and is carried out by the project’s rules on version number bumping.

Creating a release branch

Release branches are created from the develop branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of develop is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:

$ git checkout -b release-1.2 develop
Switched to a new branch "release-1.2"
$ ./bump-version.sh 1.2
Files modified successfully, version bumped to 1.2.
$ git commit -a -m "Bumped version number to 1.2"
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)
 
After creating a new branch and switching to it, we bump the version number. Here, bump-version.sh is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that some files change.) Then, the bumped version number is committed.
This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the develop branch). Adding large new features here is strictly prohibited. They must be merged into develop, and therefore, wait for the next big release.

Finishing a release branch

When the state of the release branch is ready to become a real release, some actions need to be carried out. First, the release branch is merged into master (since every commit on master is a new release by definition, remember). Next, that commit on master must be tagged for easy future reference to this historical version. Finally, the changes made on the release branch need to be merged back into develop, so that future releases also contain these bug fixes.
The first two steps in Git:

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2
 
The release is now done, and tagged for future reference.
Edit: You might as well want to use the -s or -u flags to sign your tag cryptographically.
To keep the changes made in the release branch, we need to merge those back into develop, though. In Git:

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
 
This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.
Now we are really done and the release branch may be removed, since we don’t need it anymore:

$ git branch -d release-1.2
Deleted branch release-1.2 (was ff452fe).

Hotfix branches


May branch off from: master
Must merge back into: develop and master
Branch naming convention: hotfix-*
Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.
The essence is that work of team members (on the develop branch) can continue, while another person is preparing a quick production fix.

Creating the hotfix branch

Hotfix branches are created from the master branch. For example, say version 1.2 is the current production release running live and causing troubles due to a severe bug. But changes on develop are yet unstable. We may then branch off a hotfix branch and start fixing the problem:

$ git checkout -b hotfix-1.2.1 master
Switched to a new branch "hotfix-1.2.1"
$ ./bump-version.sh 1.2.1
Files modified successfully, version bumped to 1.2.1.
$ git commit -a -m "Bumped version number to 1.2.1"
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
1 files changed, 1 insertions(+), 1 deletions(-)
 
Don’t forget to bump the version number after branching off!
Then, fix the bug and commit the fix in one or more separate commits.

$ git commit -m "Fixed severe production problem"
[hotfix-1.2.1 abbe5d6] Fixed severe production problem
5 files changed, 32 insertions(+), 17 deletions(-)
 
Finishing a hotfix branch
When finished, the bugfix needs to be merged back into master, but also needs to be merged back into develop, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished.

First, update master and tag the release.
 
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2.1

Edit: You might as well want to use the -s or -u flags to sign your tag cryptographically.
Next, include the bugfix in develop, too:
 
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)

The one exception to the rule here is that, when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of develop. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into develop too, when the release branch is finished. (If work in develop immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into develop now already as well.)
Finally, remove the temporary branch:
 
$ git branch -d hotfix-1.2.1
Deleted branch hotfix-1.2.1 (was abbe5d6).

Summary

While there is nothing really shocking new to this branching model, the “big picture” figure that this post began with has turned out to be tremendously useful in our projects. It forms an elegant mental model that is easy to comprehend and allows team members to develop a shared understanding of the branching and releasing processes.
A high-quality PDF version of the figure is provided here. Go ahead and hang it on the wall for quick reference at any time.

How to delete a remote GIT branch


From Chapter 3 of Pro Git by Scott Chacon:

Deleting Remote Branches

Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s master branch (or whatever branch your stable codeline is in). You can delete a remote branch using the rather obtuse syntax git push [remotename] :[branch]. If you want to delete your serverfix branch from the server, you run the following:
$ git push origin :serverfix
To git@github.com:schacon/simplegit.git
 - [deleted]         serverfix
Boom. No more branch on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] syntax that we went over a bit earlier. If you leave off the [localbranch] portion, then you’re basically saying, “Take nothing on my side and make it be [remotebranch].”

15 de septiembre de 2011

Después de haber laburado más de 10 horas hoy....

.... llegar al final del día logrando esto, es.... en un modo muy particular, maravilloso! jeje

Acá la cosa en cuestión que me hizo feliz ver:


----------------------------------------------------------------------
Ran 414 tests in 232.764s

OK
Destroying test database for alias 'default' ('test_cpi_mrp3')...


Sí señor! Sí señor! Ahora sí puedo hacer un push a origin e irme a dormir :)

19 de julio de 2011

Rename a GIT branch

One of the(bunch of) features of GIT that make it a delight to use while developing is the branching capabilities.

Using a good branching model even facilitates the collaboration when working with a team and helps going towards better results.

But, well, let's get to the point: sometimes it happens that you create a branch and later on you realize that the name you gave to it was not the best. Nevermind: you can painlessly rename it this way:

git branch -m old_branch_name new_branch_name

Yes! GIT rules! :)

7 de julio de 2011

How to amend a commit message in GIT


If the commit you want to fix isn’t the most recent one:
  1. git rebase --interactive $parent_of_flawed_commit
    If you want to fix several flawed commits, pass the parent of the oldest one of them.
  2. An editor will come up, with a list of all commits since the one you gave.
    1. Change pick to reword (or on old versions of Git, to edit) in front of any commits you want to fix.
    2. Once you save, git will replay the listed commits.
  3. Git will drop back you into your editor for every commit you said you want to reword, and into the shell for every commit you wanted to edit. If you’re in the shell:
    1. Change the commit in any way you like.
    2. git commit --amend
    3. git rebase --continue
Most of this sequence will be explained to you by the output of the various commands as you go. It’s very easy, you don’t need to memorise it – just remember that git rebase --interactive lets you correct commits no matter how long ago they were.

Source: link.

UPDATE:

Another way to go:

git commit --amend
Used to amend the tip of the current branch. Prepare the tree object you would want to replace the latest commit as usual (this includes the usual -i/-o and explicit paths), and the commit log editor is seeded with the commit message from the tip of the current branch. The commit you create replaces the current tip -- if it was a merge, it will have the parents of the current tip as parents -- so the current top commit is discarded.
It is a rough equivalent for:
$ git reset --soft HEAD^
$ ... do something else to come up with the right tree ...
$ git commit -c ORIG_HEAD
but can be used to amend a merge commit.

Source: link.