Xfce Wiki

Sub domains
 

This is an old revision of the document!


Git Tips and Tricks

Shortcut URLS

If you clone a lot of Xfce repositories, you can set a shortcut so you don't have to type out the full URL all the time. Simply run:

git config --global 'url.ssh://git.xfce.org/git/.insteadOf' xfce:

After this, you'll be able to do, for example:

git clone xfce:xfce/xfdesktop

and Git will automatically rewrite it to the correct URL. You can of course do this with git: and http: URLs as well.

Different Local Username?

If your ssh username is not the same as your local username, you can make an entry in $HOME/.ssh/config (create it if it doesn't exist) so you don't have to type it each time:

Host git.xfce.org
    User $USERNAME

Of course, replace $USERNAME with your actual username.

Branch Auto-Pushing

If you have a relatively new version of Git on your machine, you may get this message after running git push:

warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated.  This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning:   'nothing'  : Do not push anything
warning:   'matching' : Push all matching branches (default)
warning:   'tracking' : Push the current branch to whatever it is tracking
warning:   'current'  : Push the current branch

This warning is harmless, but you might want to change the value both to make your pushes “safer” and to get rid of the warning. Personally, I set mine to “tracking”:

git config --global push.default tracking

My rationale here is:

  1. Using 'nothing' is annoying: you have to specify the full name to push each time (e.g. git push origin master).
  2. Using 'current' could result in you accidentally pushing a new branch (that is, one that doesn't exist on the server) by accident.
  3. Using 'matching' will push all local branches that exist on the server. If you had some commits in another local tracking branch that you forgot about but didn't want to push yet, these will get pushed anyway.
  4. Using 'tracking' will only push the current branch, and then only if the branch already exists on the server. Yes, this means if you want to push multiple branches you have to push several times, but how often do you need to do that? It also means that if you're pushing a new branch, you have to explicitly name the branch on the command line the first time you push it, but, again, how often do you do that?