Learn Sourcetree to request supplies for your space station. Want to master the world of Bitbucket? As a future master-of-the-universe, you need to make sure to order all the right supplies. This mission provides two tools to get you going: Bitbucket and Sourcetree.
Sourcetree allows you to search for and clone remote repositories within its simple user interface. Sourcetree for Windows Enterprise Install, update, and manage Sourcetree at scale in your managed enterprise environment. Git and mercurial desktop client. Git and mercurial desktop client. Document collaboration. Collaborate visually on any projects. See more products. Great teamwork requires more than just great tools. Check out our proven methods, guides, and exercises that help make. Mar 11, 2020 Commit files. Click Commit in the toolbar.; Select the files to commit in the Pending files panel.; Enter a commit message. Click Commit at the bottom of the window.; To remove a file from staging, clear the checkbox next to the staged file. There are different ways to access Azure DevOps repositories. Accessing Azure DevOps using Visual Studio is very easy and it is the most used way. Earlier I discussed how to connect Azure DevOps Repo.
If you want to access GitLab via SourceTree, you can connect it with an account profile now. Another method is to connect GitLab by using the clone function with SSH key.
What Will We Learn (Method 1)
- Access GitLab with personal access token
What Will We Learn (Method 2)
- Create SSH key
- Access GitLab via SourceTree with SSH key
Method 1: Connect with Remote (Account Profile)
Since SourceTree 3.0, it adds support for additional remote hosting services. They are GitHub Enterprise, Microsoft Visual Studio Team Services, and GitLab (Cloud, CE, EE).
Create Personal Access Token
To connect GitLab with Remote, personal access token is required for authentication. To create personal access token, login GitLab and go to Settings.
After that, select Access Tokens from the sidebar. You will create your personal access token here. Give access token a name. You are able to set an expiry date for your access token. By leaving it blank, access token will never expire. Next check the api and read_user checkbox, it is required for SourceTree to connect to GitLab remotely. Click on Create personal access token to complete the setup.
Next open up your SourceTree, click on Remote and click on Add an account.
Select GitLab as the hosting services, and choose HTTPS as the Preferred Protocol. Click on Refresh Personal Access Token.
You will be prompted to enter the username and password. After entering the username and password then press OK to continue.
Do take note that email address you used to login GitLab is not your username. If you do not know your username. Go to GitLab and click on the top right profile icon. The text after @ is your username. In this example, it would be aword-test.
Furthermore, the password is your personal access token code. It only shows you once you created your personal access token. Make sure save your personal access token code in a safe place.
Then you have completed the steps to connect GitLab with SourceTree. If you connect successfully, you will able to see your repositories in SourceTree.
Method 2: Connect with SSH Key
This method is useful for users who are not using SourceTree 3.0 and above.
What is SSH Key
The Secure Shell (SSH) key is based on the principle of Public-key cryptography. It is used as a way of authentication. By generating an SSH key pair, you will get a private key and a public key. You can image public key as a padlock. You can distribute it to any systems on the Internet. Private key is like a key of the padlock. You should keep the private key securely and avoid it from being compromised. To access any system with public key, you need to use the private key to authenticate yourself.
Create SSH Key
To create SSH key, you need to generate your own SSH key with SourceTree. Go to Tools and select Create or Import SSH Keys.
Click on Generate to create SSH Key. Move your mouse cursor within the PuTTY Key Generator continuing to generate the SSH Key.
After SSH Key is generated, type your own Key passphrase for your SSH Key. Key passphrase is like a password to protect your SSH private key. Save your public key and private key for future use.
Add SSH Public Key to GitLab
To add your SSH Key to GitLab, you need to log into you GitLab account. Click on your profile icon on the top right corner, then select Settings. Click on SSH Keys on the side menu.
Copy your public key inside your PuTTY Key Generator, then paste it into GitLab. Click on Add Key to add your SSH Key into the GitLab.
Add SSH Private Key to SourceTree
To add private key to SourceTree, Click on Tools then click Launch SSH Agent…
You will find SSH Agent named as Pageant on the taskbar. Double click on Pageant.
Now click on Add Key. Add your private key which have been saved earlier.
Clone Repository to Access GitLab via SourceTree
Go into your projects in your GitLab. Copy the SSH URL.
In SourceTree, click on Clone. Paste the repository URL into Source Path. Click on Clone, you have successfully connected GitLab with SourceTree. Now you are able to pull and push your code to GitLab with SourceTree.Back to list
October 5, 2019 • 3 min to read
A list of git daily basis commands with Sourcetree GUI
Remembering many git commands and also doing it in the terminal can be hard if you don't have too much practice. Graphical User Interfaces (GUI's) can make your life easier and improve your productivity. One of that is the Sourcetree.
Sourcetree is a free Git client for Windows and Mac that simplifies how you interact with your Git repositories so you can focus on coding. It enables you visualize and manage your repositories through a simple Git GUI.
In this post we will show how to run some git daily basis commands with the Sourcetree GUI.
Shows the commit logs.
git log (doc)
In Sourcetree we can check the log in the History tab.
Record changes to the repository
git commit -m <message> [--amend] (doc)
In Sourcetree you can achieve the same result clicking in the rounded Commit button at the top left corner, write the message in the text box and commit it by clicking the right bottom button.
Adding the amend option you will replace the tip of the current branch by creating a new commit. For doing this in Sourcetree you need select the Commit Options in the right top of the commit input box and select the option Amend last commit.
Show changes between commits, commit and working tree, etc
git diff <commit1> <commit2> (doc)
For doing the same in Sourcetree you just need select 2 commits in the History.
git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the
git stash push -m <message> (doc)
In Sourcetree for push a new stash you need select the Stash button in the top toolbar.
For apply or delete a stash you can use the Stashes menu in the sidebar.
Switch branches or restore working tree files
git checkout -b <branch> (doc)
In Sourcetree first you need right click in the commit you want and select the Branch option.
Then you just need add the branch name and confirm.
Adds a remote named
<name> for the repository at
git remote add <name> <url> (doc)
For adding a remote you need first create a remote repository in some host service like Github or Bitbucket. For example, after create a repository on Github you have some like that:
To add this remote in Sourcetree first you need right click on the Workspace menu in the sidebar.
Then add the remote
<name> (usually defined as 'origin') and
<url> in the fields and click in OK. That's it. Your new branch is ready.
Join two or more development histories together
Sourcetree Web Browser
git merge <branch> (doc)
For merge branch in Sourcetree you just need right click in the branch commit that you want and choose the option Merge.
If you have some conflict you can also fix it by right clicking in the conflicted file, select the Resolve Conflicts and pick the desired option.
Resolve Using 'Mine' means you want use the solution of your current branch and
Resolve Using `Theirs' means you want replace the solution for the selected commit.
To Squash commits you should use rebase command in interactive mode. Rebasing interactively means that you have a chance to edit the commits which are rebased. You can reorder the commits, and you can remove them (weeding out bad or otherwise unwanted patches).
Start it with the last commit you want to retain as-is:
git rebase -i <after-this-commit> (doc)
An editor will be fired up with all the commits in your current branch (ignoring merge commits), which come after the given commit. You can reorder the commits in this list to your heart’s content, and you can remove them. The list looks more or less like this:
You can squash commits changing the word
squash (or just
s) next to it. The result would be:
For squash commits in Sourcetree first you need right click in the commit before that you want and select the option
Rebase children of <commit> interactively....
Then select the commits you want squash and confirm. You can also edit the commit message if you want.
In this post we learned some useful git daily commands (like commit, merge, stash, etc.) using the Sourcetree GUI. It enables you visualize and manage your repositories improving your productivity and making you focus on what matters: coding.
If you have some suggestion please let me know commenting below or submitting a PR for this post :).
This project is open-source, so if something is missing or if you found some part confusing, please submit a pull-request in theGithubrepository for this post with your suggestions for improvement. It is a simple and effective way to contribute to the web development community.