Presentation is loading. Please wait.

Presentation is loading. Please wait.

(Advanced) Web Application Development

Similar presentations


Presentation on theme: "(Advanced) Web Application Development"— Presentation transcript:

1 (Advanced) Web Application Development
More Git for Version Source Control Diagrams from Bruce Scharlau, University of Aberdeen, 2017

2 Bruce Scharlau, University of Aberdeen, 2017
Discuss with the person next to you why we want you to use Git for your work Bruce Scharlau, University of Aberdeen, 2017

3 Git provides a means for both:
a global ‘what if’ as well as a global ‘undo’ in our projects Bruce Scharlau, University of Aberdeen, 2017

4 Where we’re going today
Look at why we need version source control Look at how Git works for better understanding Try some ideas for better insight to Git Bruce Scharlau, University of Aberdeen, 2017

5 Bruce Scharlau, University of Aberdeen, 2017
Version control provides an undo for us so we can make changes with a safety net Bruce Scharlau, University of Aberdeen, 2017

6 There are many types of version control
Some were local, others were server based, and some were distributed Git is a distributed version control system Git is used for growing number of projects including: linux, ruby and rails and many gems Bruce Scharlau, University of Aberdeen, 2017

7 Git tracks file changes
Git is a version control system which tracks changes in files inside its repository As long as you’ve put the file into the repository tracking system, Git will know what’s been changed Bruce Scharlau, University of Aberdeen, 2017

8 Use one Git repository per project
Create a new project in its own folder and then create a repository in the project git init git add . git commit –m ‘initial commit’ Bruce Scharlau, University of Aberdeen, 2017

9 Git tracks changes in files
Git watches files and tracks the differences between different versions of files and stores those differences – hence it’s very lightweight and fast It only keeps the differences between versions Bruce Scharlau, University of Aberdeen, 2017

10 Git provides snapshots
others Other systems track changes in files, eg subversion, CVS, etc Git Git stores data as snapshots, so a clone is the full backup of project Bruce Scharlau, University of Aberdeen, 2017

11 Git has three areas of operation
Modified is changed, uncommitted file Committed means data is in repository Staged is modified file marked to go into commit snapshot Bruce Scharlau, University of Aberdeen, 2017

12 Four file status options
Staged is what will be added to next commit Untracked is ignored Modified is changed, but not added to stage for commit Unmodified is unchanged Bruce Scharlau, University of Aberdeen, 2017

13 You can drop items from staging
Remove from ‘staged’ with ‘reset’ and ‘checkout’ to discard changes NOTE: discarded changes are ‘lost’ and unrecoverable Bruce Scharlau, University of Aberdeen, 2017

14 Rolling back commit changes
Use ‘reset’ to undo commits has the details Hard and Soft resets move you back in commits Bruce Scharlau, University of Aberdeen, 2017

15 Tags let you refer to versions
Git tag is a simple way to refer to previous commits Git tag is better than remembering/using the hash value of a commit Use ‘git tag <name>’ to create a tag And ‘git tag’ to list tags Bruce Scharlau, University of Aberdeen, 2017

16 Bruce Scharlau, University of Aberdeen, 2017
Demo the Git basics Show git tag, untracked, tracked, tracked and modified, and staged, plus committed and how to work with these Git immersion from labs 13->19 GIT DEMO Show tagging versions,thenuntracked, tracked, tracked and modified, and staged, plus committed and how to work with these git tag <name>git checkout v1^ to get previous version checkout (HEAD^)change files in working dir with git checkout <filename>change file in stage and using git reset HEAD <filename> to remove file from stage and then us git checkout <filename> to be back where started create unwanted commit and then use 'git revert HEAD' to roll back, which pops you into editor.. save and close and back to where were can use 'git reset --hard <tag> to roll back to previous tag - not good in group projects though Can also do a lot more, but this gives basic idea Bruce Scharlau, University of Aberdeen, 2017

17 Git lets us try new ideas without messing up current work
Bruce Scharlau, University of Aberdeen, 2017

18 Git lets you create branches
A repository has a ‘master’ branch of the code and you can create more (just like a tree) for new parts – for example a new feature in the app Bruce Scharlau, University of Aberdeen, 2017

19 Branches are easy to toss away
If you change your mind you can remove a branch – just like lopping off a tree branch Makes it easy to ‘try before you buy’ Bruce Scharlau, University of Aberdeen, 2017

20 We can also merge a branch to master
If we do like the new code we can ‘merge’ it into the master branch of the code and thus drop the branch Bruce Scharlau, University of Aberdeen, 2017

21 Git works with remote repositories
To ensure our code survives beyond our laptop with a remote repository. This removes the hassle of carefully copying the code to other locations via USB sticks, without overwriting versions. Bruce Scharlau, University of Aberdeen, 2017

22 Use ssh keys for remote repositories
Remote repositories are checked using public and private keys instead of logins Git will have set one up for you when it was installed If not follow instructions at … Bruce Scharlau, University of Aberdeen, 2017

23 Create private repos for your work
You can use a private repos at Heroku (not just for Rails apps) Create account and then one repo per project to ensure you don’t loose anything Bruce Scharlau, University of Aberdeen, 2017

24 Use a repo for ALL coursework
Github is payable for private projects, and free only for PUBLIC ones. Check if the Github ‘student’ account covers your needs Use Heroku or Bitbucket instead Bruce Scharlau, University of Aberdeen, 2017

25 Using public repos exposes you to plagiarism
You are potentially guilty of plagiarism by using public repositories as others can copy your work. Use private repositories for coursework at Bitbucket or Heroku instead Bruce Scharlau, University of Aberdeen, 2017

26 Bruce Scharlau, University of Aberdeen, 2017
With remote repos you can collaborate on work: ‘undo’ things, ‘try ideas’ and ‘merge’ work Bruce Scharlau, University of Aberdeen, 2017

27 Collaborate with others via remote repo
Remote repos mean we can share our work with collaborators and Git will keep track of who made which change Bruce Scharlau, University of Aberdeen, 2017

28 Using git in teams takes practice
Individuals need to add steps in work when collaborating to avoid creating a mess of their projects Make the effort now to learn this and future group projects will flow much more smoothly Bruce Scharlau, University of Aberdeen, 2017

29 Teams need workflow method
Discuss with the person next to you what workflow is needed with teams using version control Bruce Scharlau, University of Aberdeen, 2017

30 Local and remote need to be kept synced
Teams need something like: Do your work, and then pull changes from remote, then run tests to see what’s broken, then fix code from changes team has made, then test again, then pull remote again to ensure up to date, Only then do you push when all tests pass Bruce Scharlau, University of Aberdeen, 2017

31 Local and remote need to be kept synced
Do your work, and then pull changes from remote Only then do you push when all tests pass then run tests to see what’s broken then fix code from changes team has made, then test again then pull remote again to ensure up to date Bruce Scharlau, University of Aberdeen, 2017

32 Overlap of agile methods with git usage
Team need to prioritise tasks in code, and decide who’s working on what so overlapping work is minimized Use Trello or Issues to track work/tasks Bruce Scharlau, University of Aberdeen, 2017

33 Go add Git to your projects
Go back to your ongoing examples and create Git repositories inside each of them. Start using Git repos (both local & remote) for all of your work Bruce Scharlau, University of Aberdeen, 2017

34 We can deploy to remote sites like Heroku with Git
Detailed instructions for use with Cloud 9 at References at And example Bruce Scharlau, University of Aberdeen, 2017

35 Why should we bother with Heroku?
We can run large apps already on our own systems and C9 and Codio let us show these to others, so why bother with Heroku? Think about this yourself, and then discuss with the person next to you. Bruce Scharlau, University of Aberdeen, 2017

36 Install Heroku for your system
$source<(curl -sL For Cloud 9 and others download CLI from Heroku – detailed instructions to follow there Then use ‘heroku create’ to add heroku to a git repository and you can use this to deploy git push heroku master Bruce Scharlau, University of Aberdeen, 2017

37 Bruce Scharlau, University of Aberdeen, 2017
PG and Heroku for Linux Use these instructions for putting Postgresql in your Linux system Install Heroku from details here and in particular ‘other Linux options’ under ‘standalone installation’ which use the command $ curl | sh Bruce Scharlau, University of Aberdeen, 2017

38 Modify the Gemfile for Postgresql
group :development, :test do gem 'sqlite3’ gem 'byebug', platform: :mri end group :production do gem 'pg' end Use special bundle install so that you don’t need Postygresql on your machine Optional flag $bundle install --without production Bruce Scharlau, University of Aberdeen, 2017

39 Don’t forget the extras
Check Heroku details for more… viewing logs, using database, starting a console Heroku logs – tail (watch the app log) Heroku pg ( database details) Heroku run rake db:migrate Bruce Scharlau, University of Aberdeen, 2017


Download ppt "(Advanced) Web Application Development"

Similar presentations


Ads by Google