Working with Git & Mercurial:

    Starting with Git/Mercurial

    Introduction

    We provide this guide in order to help our users get used to Git & Mercurial Integration at SourceLair and make the most out of it.

    This guide assumes that you already

    • have a free SourceLair account
    • know that the most productive tool of SourceLair is Command Palette (Ctrl+Shift+P).

    You can learn how to use git here.

    Let's start!

    Visual Status for Git/Mercurial

    Each time you create or update a file, it gets colored according to its Git or Hg status;

    • Green, for new files Status Green
    • Orange, for existing, modified files (uncommitted changes) Status Orange
    • Blue, for existing, unmodified files (no changes after commit) Status Blue That way you are always aware if you have uncommitted changes in your project, without toggling the commit message prompt.

    Next step, connect your GitHub account.

    Connecting your account with GitHub

    To connect your account to GitHub you have to:

    1. Go to sourcelair.com and "Sign up with GitHub" (or "Sign in with GitHub" if you have already an account).

    2. Complete the authorization process.

    Attention: To connect with GitHub, the email that you use at SourceLair has to be also registered at GitHub.

    Next step, if you haven't connected your account with Github, add your public key to Github or BitBucket.

    Add your public key to GitHub/Bitbucket

    If you have connected your account to GitHub you do not need to do this procedure.

    To add your public key to GitHub/BitBucket, the first thing you need to do is go to your Account Settings (at the top of the left sidebar) at SourceLair and copy your public key to the clipboard.

    Follow these steps to add your SourceLair public key to GitHub:

    1. Logout and "Sign in with GitHub".
    2. Complete the authorization process.

    Follow these steps to add your SourceLair public key to Bitbucket:

    1. Log in to www.bitbucket.org.
    2. Go to Manage account menu.
    3. Select the "SSH keys" section.
    4. Click on "Add Key".
    5. Paste your key and press "Add key".

    Now you are ready to clone your Git repos from GitHub/Bitbucket and pull/push your changes in seconds.

    Next step, clone an existing project.

    Init/Clone an existing project

    You have already placed your public key on the server (e.g. GitHub, Bitbucket or private server) from which you will clone it.

    1. Copy your SSH Clone URL from this server.

    2. Log in to your SourceLair account, select Clone project and paste your SSH Clone URL.

    Clone from Github

    Connect your account with Github and then:

    1. Go to "Clone a new project"
    2. Click on "clone one of your GitHub repos". Image for clone one of your GitHub repos

    Next step, let's see the most common git commands.

    Commit

    You can commit using Command Palette (Ctrl+Shift+P) and writting commit.

    Next step, let's see push and pull.

    Push/pull

    You can push or pull using Command Palette (Ctrl+Shift+P) and writting push or pull.

    Next step, let's see commands about branches.

    Branching (create, checkout)

    You can create a new branch or checkout a branch using Command Palette (Ctrl+Shift+P), writting branch and choosing the option you want.

    Next step, let's see commands about remotes.

    Remotes

    You can easily add remotes from Command Palette (Ctrl+Shift+P). By writting remote you will be able to see the available actions, which are below:

    Remotes - CP

    For example, "add new remote" is the command you have to choose if you want to connect your server with your SourceLair account.

    Next step, advanced git commands.

    Advanced Git commands

    You can use your terminal for Git commands that are not covered by Command Palette.

    Reset uncommited changes

    $ git reset --hard
    

    Reset last n commits

    $ git reset --hard HEAD~<n>
    

    Abort Changes of a File

    $ git checkout -- <fileName>
    

    Modify the Previous Commit's Message

    $ git commit --amend
    

    Partial Change Checkin

    $ git add --edit
    

    Undo the Previous Commit

    $ git revert HEAD^
    

    Temporarily Stash Changes, Restore Later

    # After changes have been made...
    $ git stash
    
    # Do some other stuff here, like switch branches, merge other changes, etc.
    
    #Re-apply the changes
    $ git stash pop
    

    Next step, advanced mercurial commands.

    Advanced Mercurial commands

    You can use your terminal for Mercurial commands that are not covered by Command Palette.

    Reset uncommited changes

    $ hg update --clean
    

    Reset to revision

    $ hg update [-r REV]
    

    Abort Changes of a File

    $ hg revert <filename>
    

    Undo the Previous Commit

    $ hg rollback
    

    Next step, best way to continue after this mini guide.

    Next Steps

    In case you are new in web development, we have created a great guide in order to set up a professional workflow using git. You can find it here .