git tutorial
TRANSCRIPT
1Confidential and propriety Galil Software, Ltd. 2012 May 1, 2023
Git TutorialAuthor:Nael Abd Aljawad – QA Automation Leader & Engineer
2Confidential and propriety Galil Software, Ltd. 2012 25.12.11
Who Needs GIT?
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
4Confidential and propriety Galil Software, Ltd. 2012 25.12.11
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 ?
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
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
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
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
10Confidential and propriety Galil Software, Ltd. 2012 25.12.11
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
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
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
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
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?
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
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
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)
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)
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.
21Confidential and propriety Galil Software, Ltd. 2012 25.12.11
Git Basic Branches
22Confidential and propriety Galil Software, Ltd. 2012 25.12.11
23Confidential and propriety Galil Software, Ltd. 2012 25.12.11
24Confidential and propriety Galil Software, Ltd. 2012 25.12.11
Software Engineer
25Confidential and propriety Galil Software, Ltd. 2012 25.12.11
Software Engineer
26Confidential and propriety Galil Software, Ltd. 2012 25.12.11
Thank You Nael Abd Aljawad – QA Automation Leader & Engineer