Git 2.3 came out

    Greetings, colleagues! This morning, the github published a detailed article about a freshly released version of git. You can pick it up, as usual, on the official website , and under the cut, a brief translation of what's new and interesting: push-to-deploy, manual control of SSH parameters, a way to prevent cron scripts from hanging with the git client, and much more.



    Push to deploy



    The ability to configure the remote repository in such a way that the received push automatically makes a checkout (provided that there were no local changes on this computer, of course). This function is convenient for test and internal deploy: there is no need to install additional scripts, push to the server automatically changes its files in the working copy, and not only adds them to the repository.

    The authors warn that it is not recommended to use this functionality for deploy production servers, as there are a number of side effects:
    • Next to the working copy files there will be a .git directory, which you will need to take care of hiding from the web server separately.
    • Working copy files are not updated all at once in one transaction, but one at a time, so for a short period of time the server files may be in an inconsistent state.
    • If after updating the files the server requires assembly, then you still need to use scripts.


    Fast cloning based on an already cloned local repository



    The new --dissociate key allows you to pick up the necessary files from the local repository specified with --reference during cloning: this can greatly reduce the cloning time and network load if a copy of the desired repository is already somewhere on the disk:

    git clone --reference ../oldclone --dissociate https://github.com/gitster/git.git
    


    More conservative default git push behavior



    Remember, recently when pushing branches, git constantly recommended setting “push.default”, hinting that soon the default behavior will change? It has changed. Now, if the name of the local branch is different from the name of the upstream branch, then git will refuse to push without telling remote to protect you from push in the wrong branch:

    git checkout -b experimental origin/master
    git commit -a -m 'Experimental changes'
    git push # Вот это теперь не сработает - разработчик явно хочет сделать push в 'experimental', а не в 'master'.
    


    SSH connection parameters can now be set manually



    Using the GIT_SSH_COMMAND environment variable, you can now precisely configure how git will use ssh. Finally, you can easily make different private keys for different repositories without modifying user-wide "~ / .ssh / config":

    GIT_SSH_COMMAND='ssh -i git_id' git clone host:repo.git
    


    Ability to disable user input during automation



    By setting the GIT_TERMINAL_PROMPT environment variable to 0, user input can be disabled. This is useful when git is called from an automation script and user input is not implied - now, with authorization errors, git will not prompt for a username / password and thereby suspend the cron script.

    On the little things


    • Reduced unnecessary file rewriting during checkout so that smaller working copy files are in an inconsistent state when push-to-deploy.
    • Git branch -d (delete branch) and git branch -m (rename branch) now support the --force switch.


    All



    If I missed something, misunderstood or translated incorrectly - write.

    Also popular now: