Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with Git and Bitbucket

Similar presentations


Presentation on theme: "Getting Started with Git and Bitbucket"— Presentation transcript:

1 Getting Started with Git and Bitbucket

2 Overview This presentation covers every basic command you need to do the vast majority of the things you’ll eventually spend your time doing with Git. You should be able: to configure and initialize a repository, begin and stop tracking files, and stage and commit changes. to ignore certain files and file patterns, to undo mistakes quickly and easily, to browse the history of your project and view changes between commits, and to push and pull from remote repositories.

3 Distributed Version Control Systems (Full Repository on all machines)

4 Git Project Structure (Local Machine)

5 Account/Tool Requirements
You must have A Bitbucket Account, and Git installed on your PC/Laptop.

6 What is Bitbucket? Bitbucket is a web-based hosting service (i.e. a server) for projects that use either the Mercurial or Git revision control systems. It allows software engineers to share repositories and collaborate on projects. Bitbucket offers both commercial plans and free accounts. It offers free accounts with an unlimited number of private repositories (which can have up to five users in the case of free accounts).

7 Create Bitbucket Account
You must to create your own Bitbucket account. ( Use your AIT Student to create account. Refer to “Create a Bitbucket Account” instructions on moodle or follow the link -

8 Setup Version Control (Git)
When you use Bitbucket, you want to transfer your files/code between your local system and Bitbucket. This is where a distributed version control system (DVCS), such as Git, comes in! Bitbucket supports two DVCS tools: Git and Mercurial. You can use both of these tools by typing commands from a terminal or SourceTree. SourceTree is an application with a user interface that lets you do everything you can do with Git and Mercurial without learning a lot of new commands.

9 Setup Version Control (Git)
Refer to “Setup SourceTree” instructions on moodle or follow the link You should setup SourceTree on your own PC or laptop. It should already be setup in the AIT labs.

10 Getting Started with Repositories
Using Bitbucket and Sourcetree

11 Introduction This section focuses on the basic DVCS workflow activities between Bitbucket and your local system. These activities or functions are clone, add, commit, push, and pull.

12 Tutorial Refer to SourceTree tutorial for details of the following slides:

13 Step 1. Create a repository
Initially, the repository you create in Bitbucket is going to be empty without any files/code in it. (Remember to login to your account) That's okay because you will start adding some files to it soon. This Bitbucket repository will be the central repository for your files, which means that others can access that repository if you give them permission.

14 Step 1. Create a repository
You will also copy a version of that repository to your local system (later!).

15 Step 2. Explore your new repository

16 Copy your repository and add files

17 Clone (or Copy) A Repository
Now that you have a place on a server to add and share files, you need a way to get to it from your local system. To set that up, you want to copy the Bitbucket repository to your system. SourceTree refers to copying a repository as "cloning" it. When you clone a repository, you create a connection between the Bitbucket server and your local system.

18 Step 3. Clone your repository to your local system
Click “Clone in SourceTree” button. From the Clone New dialog box, update the Destination Path to <local directory>/repos/bitbucketstationsupplies. This destination path refers to the directory you just created with the folder for the repository. The Name field remains the same with the folder name of the repository.

19 Step 4. Create a file, add it locally, and push it to Bitbucket
Go to your local directory/folder for your local repository “bitbucketstationsupplies”. Create a word document (supplies.doc) with some text in it. For example: “space ice cream nerf darts telescope light shield”

20 Step 4. Create a file, add it locally, and push it to Bitbucket
File is now unstaged.

21 Step 4. Create a file, add it locally, and push it to Bitbucket
Click the Add button at the top to stage the file, making it ready to commit. Adding a file moves changes from the working directory to the staging area. The staging area gives you the opportunity to prepare a snapshot of a set of changes before committing them to the official history.

22 Step 4. Create a file, add it locally, and push it to Bitbucket
File is now staged.

23 Step 4. Create a file, add it locally, and push it to Bitbucket
Click the Commit button at the top to commit the file. In the message box, enter "Initial commit.“ Click the Commit button under the box. Your new file is now committed to the project history.

24 Step 4. Create a file, add it locally, and push it to Bitbucket

25 Step 4. Create a file, add it locally, and push it to Bitbucket
Up until this point, everything you have done is on your local system and is invisible to your Bitbucket repository until you push those changes to your remote Bitbucket repository. From SourceTree, click the Push button to push your committed changes. Pushing lets you move one or more commits to another repository, which serves as a convenient way to publish contributions.

26 Step 4. Create a file, add it locally, and push it to Bitbucket
Under the Push? column, select the master branch to indicate that you are pushing that branch to origin and click OK.

27 Step 4. Create a file, add it locally, and push it to Bitbucket
Go to the BitbucketStationSupplies repository in your browser and click the Commits item on the menu bar. You should see a single commit on your repository. Bitbucket combines all the things you just did into that commit and shows it to you.

28 Pull changes from your repository on Bitbucket

29 Step 5. Create a file in Bitbucket
From the Source page, click New file. You are able to see this button because you have already added at least one file to the repository A page for creating the new file opens, as shown in the following image.

30 Step 5. Create a file in Bitbucket

31 Step 5. Create a file in Bitbucket
Enter supplyrequest in the filename field. Select HTML from the Syntax mode list. Add the following HTML code to the text area: <p>We are requesting additional supplies. Please send us the following:</p><ul> <li>space ice cream</li> <li>nerf darts</li> <li>telescope light shield</li></ul>

32 Step 5. Create a file in Bitbucket
Click Commit. The Commit message field appears with the message: supplyrequest created online with Bitbucket. Click Commit under the message field. You now have a new file in Bitbucket! You are taken to a page with details of the commit, where you can see the change you just made:

33 Step 5. Create a file in Bitbucket

34 Step 5. Create a file in Bitbucket
If you want to see a list of the commits you've made so far, click Commits link on the left side.

35 Step 6. Pull changes from a remote repository
Now we need to get the new file onto your local system. The process is pretty straight forward, basically just the reverse of the push you used to get the supplies.doc file into Bitbucket.

36 Step 6. Pull changes from a remote repository
Open SourceTree. Click the Pull button. A popup appears to indicate that you are merging the file from Bitbucket to your local repository. See next slide.

37 Step 6. Pull changes from a remote repository

38 Step 6. Pull changes from a remote repository
Click OK from this box. Sourcetree updates with a description of the merged file. Navigate to the location of your repository directory on your local system and find the file you just added.

39 Summary

40 Some facts about Repositories
You have access to all files in a repository, whether you are working on one file or multiple files. Each repository belongs to a user account or a team. The person who creates the repository is its owner. The repository owner is the only person who can delete the repository. A user or a team can have an unlimited number of public and private repositories. A code project can consist of multiple repositories across multiple accounts but can also be a single repository from a single account.


Download ppt "Getting Started with Git and Bitbucket"

Similar presentations


Ads by Google