git tutorial

26
1 Confidential and propriety Galil Software, Ltd. 2012 7/5/22 Git Tutorial hor: l Abd Aljawad – QA Automation Leader & Engine

Upload: nael-abd-eljawad

Post on 21-Jan-2017

180 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Git Tutorial

1Confidential and propriety Galil Software, Ltd. 2012 May 1, 2023

Git TutorialAuthor:Nael Abd Aljawad – QA Automation Leader & Engineer

Page 2: Git Tutorial

2Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Who Needs GIT?

Page 3: Git Tutorial

3Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Create things Save things Edit things Save the thing again

Our Daily Tasks

When you did it, why you did it and what the contents of the change were, open for reviews at any time In the future

Page 4: Git Tutorial

4Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Page 5: Git Tutorial

5Confidential and propriety Galil Software, Ltd. 2012 25.12.11

A distributed version control system

keep track of changes made to files merge the contributions of multiple developers facilitates backups helps to identify/fix conflicts Accountability (who wrote the code?) Software branches - different versions of software need to be maintained, ensure bug fixes shared

What is Git ?

Page 6: Git Tutorial

6Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Is a central place in which an aggregation of data is kept and maintained in an organized way, usually in computer storage

A repository can be a place where multiple databases or files are located for distribution over a network, or a repository can be a location that is directly accessible to the user without having to travel across a network

Git Repository

Page 7: Git Tutorial

7Confidential and propriety Galil Software, Ltd. 2012 25.12.11

The git “index” is where you place files you want committed to the git repository Before you “commit” (check-in) files to the git repository, you need to first place the files in the git

“index”

Files in the git index are files that git would commit to the git repository if you used the git commit command.

Files in the git index don’t get committed to the repository until you use the git commit command

Git Index

Page 8: Git Tutorial

8Confidential and propriety Galil Software, Ltd. 2012 25.12.11

The git index goes by many names. But they all refer to the same thing. Some of the names you may have heard: Index Cache Directory cache Current directory cache Staging area Staged files

An index by any other name

Page 9: Git Tutorial

9Confidential and propriety Galil Software, Ltd. 2012 25.12.11

A snapshot is the state of something (e.g. a folder) at a specific point in time. In this case, snapshot means the current content of the test branch, this doesn't have to be the head revision

A new commit is created by taking a snapshot of the Index A commit is a snapshot of the repo at a given time

Git Snapshot

Page 10: Git Tutorial

10Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Page 11: Git Tutorial

11Confidential and propriety Galil Software, Ltd. 2012 25.12.11

$ git init “Project Name”

Creates a directory, a folder that can contain the project files (Repository)

Git Init

Page 12: Git Tutorial

12Confidential and propriety Galil Software, Ltd. 2012 25.12.11

$ git commit –m

Is the keyword that actually permanently records a historical version or snapshot of the files as they exist at the given point in time

Git Commit

Page 13: Git Tutorial

13Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Workspace is what you see in your computers file system The index is an invisible space where you can add files you want to commit You can always commit to your local repository - it's really stored in the .git folder A remote repository can be on another computer. it may not be reachable all the time

Store Places

Page 14: Git Tutorial

14Confidential and propriety Galil Software, Ltd. 2012 25.12.11

$ git add (to index)

The "add" command puts your changes into the staging area, the "commit" commands saves them to the local repository

The staging area is the place where you collect the pieces that will make up a commit

Git Add

Page 15: Git Tutorial

15Confidential and propriety Galil Software, Ltd. 2012 25.12.11

$ git commit -a -m “some stuff I did” When implementing a feature or fixing a bug you will usually need several commits to get the work

done. Or maybe it's the other way round: when you work with git you will soon find that making several small commits is quite convenient, because it helps you structure (and maybe undo) your work. Even if you made several changes, you can split those up into two commits by first adding and committing one set of files, and then adding and committing the rest.

If - on the other hand - you do not want to add the files by hand there is a convenient way to committing all the changes at once: add the -a flag to the commit

What is a good commit?

Page 16: Git Tutorial

16Confidential and propriety Galil Software, Ltd. 2012 25.12.11

You can work with several remote repositories. The most important remote repository is usually called origin

Adding a Remote Repository If you created the repository locally you can connect it to a remote repository later on: git add remote origin https://github.com/myname/myrepository.git Look into .git/config to find the information again.

Remote Repositories

Page 17: Git Tutorial

17Confidential and propriety Galil Software, Ltd. 2012 25.12.11

When you want to work with an existing remote repository you need to find out the repositories URL. The URLs may start with http, https, ssh, or git.

Two examples are: https://github.com/web-engineering/web-engineering-textbook [email protected]:web-engineering/web-engineering-textbook

Clone an existing repository

Page 18: Git Tutorial

18Confidential and propriety Galil Software, Ltd. 2012 25.12.11

When working with a remote repositories you need two now commands: push and pull

Workflow with remote (1)

Page 19: Git Tutorial

19Confidential and propriety Galil Software, Ltd. 2012 25.12.11

When you push your local commits to the remote repository you have to specify a local branch and the name of the remote repository. When you haven't worked with branches yet there is only the master branch $ git push origin master

When you pull changes from the remote repository you have to specify the local branch again (probably master) and the name of the remote repository $ git pull origin master

Now you are ready to work with git on your own. You can make a backup or publish to the world by pushing to a remote repository. But if you want to work in a team you will need to handle branches.

Workflow with remote (2)

Page 20: Git Tutorial

20Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Git Basic Branches

Master is a permanent branch which always reflects a production-ready state. So yes, it is for ready-product which can be downloaded on the market by user.

Release is a temporal supporting branch to support preparation of a new production release. This means mainly bug fixing, documentation, etc. as pointed out by minas.

Page 21: Git Tutorial

21Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Git Basic Branches

Page 22: Git Tutorial

22Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Page 23: Git Tutorial

23Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Page 24: Git Tutorial

24Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Software Engineer

Page 25: Git Tutorial

25Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Software Engineer

Page 26: Git Tutorial

26Confidential and propriety Galil Software, Ltd. 2012 25.12.11

Thank You Nael Abd Aljawad – QA Automation Leader & Engineer