Open main menu

Difference between revisions of "Git tips"

452 bytes added ,  21:53, 13 February 2011
m (type os)
Line 18: Line 18:
=== How to push changes ===
=== How to push changes ===


The important thing to realize is that when pushing changes to the remote server (aka "''origin''"), your changes '''''must''''' be based on the remote repository. Subversion allowed you, in some cases, to commit without having the most up-to-date working copy. Git doesn't.
The important thing to realize is that when pushing changes to the remote server (aka "''origin''"), your changes '''''must''''' be based on the remote repository's branch you wish to push to. Subversion allowed you, in some cases, to commit without having the most up-to-date working copy. Git doesn't.


A normal ''git push'' without any errors is one that only adds new commits, that (in their metadata) point to existing commits.
A normal ''git push'' without any errors is one that only adds new commits, that (in their metadata) point to existing commits.
Line 39: Line 39:
* '''git pull''' — Perform a ''fetch'' followed by a ''merge'' (the default behavior) or ''rebase'' (with a flag).
* '''git pull''' — Perform a ''fetch'' followed by a ''merge'' (the default behavior) or ''rebase'' (with a flag).


So in our case, if we made a few unrelated commits, we just want to apply them on top of the remote commits, and to do that we can use <tt>git pull --rebase</tt> which will get the remote changes, and reapply our local changes on top of the remote's. From that state, we could <tt>git push</tt> our changes back up.
So in our case, if we made a few unrelated commits, we just want to apply them on top of the remote commits, and to do that we can use <tt>git pull --rebase</tt> which will get the remote changes, and reapply our local changes on top of the remote's. From that state, we could run <tt>gitk</tt> or any other visualization tool, see that everything is to our liking, and <tt>git push</tt> our changes up.
 
==== Configuring <tt>git pull</tt> to rebase automatically ====
 
If you like making commits on the master branch, and want <tt>git pull</tt> to always rebase your local changes on top of the fetched commits, run this configuration command to modify the repository's <tt>.git/config</tt> file:
 
$ git config branch.master.rebase true


=== Branchy development ===
=== Branchy development ===


TODO
TODO
68

edits