DPS909 & OSD600 Winter 2017 - Git Walkthrough
Contents
Git Walkthrough: Basics
Step 1: get some source
For this walkthrough, we'll need some source code. Normally you'll write code, but for this walkthrough, we'll borrow some pre-existing code to make things easier. Let's download the Bootstrap source:
https://github.com/twbs/bootstrap/archive/v4.0.0-alpha.6.zip
Expand the zip file, and open a terminal to your bootstrap-4.0.0-alpha.6/
directory.
Step 2: start a git repo
$ cd bootstrap-4.0.0-alpha.6 $ git init
Note the presence of a new bootstrap-4.0.0-alpha.6/.git/
directory:
$ ls .git HEAD config hooks objects branches description info refs
NOTE: normally we git clone
to clone (also known as fork) a repository. We'll do that in a bit.
Step 3: adding a file
Let's inspect the current status of our repo:
$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) .editorconfig .eslintignore .gitattributes .gitignore .hound.yml .houndignore .travis.yml CHANGELOG.md CNAME CONTRIBUTING.md Gemfile Gemfile.lock Gruntfile.js ISSUE_TEMPLATE.md LICENSE README.md _config.yml bower.json composer.json dist/ docs/ grunt/ js/ nuget/ package.js package.json sache.json scss/ nothing added to commit but untracked files present (use "git add" to track)
Our Working Directory (i.e., bootstrap-4.0.0-alpha.6/
) has a lot of files and folders that are untracked (i.e., git has no record of them in its history).
We include a file in git's history by adding it to the index (also known as the staging area). Let's add the README.md
file:
$ git add README.md $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: README.md Untracked files: (use "git add <file>..." to include in what will be committed) .editorconfig .eslintignore .gitattributes .gitignore .hound.yml .houndignore .travis.yml CHANGELOG.md CNAME CONTRIBUTING.md Gemfile Gemfile.lock Gruntfile.js ISSUE_TEMPLATE.md LICENSE _config.yml bower.json composer.json dist/ docs/ grunt/ js/ nuget/ package.js package.json sache.json scss/
This time git status
continues to report our Untracked files, but also includes a new section: Changes to be committed. The README.md
file has been added to the staging area, and is ready to be commited to git's history.
We record a snapshot of our files by committing the staging area's contents:
$ git commit -m "Added README file" [master (root-commit) 03c9551] Added README file 1 file changed, 135 insertions(+) create mode 100755 README.md
Let's look at our status again:
git status On branch master Untracked files: (use "git add <file>..." to include in what will be committed) .editorconfig .eslintignore .gitattributes .gitignore .hound.yml .houndignore .travis.yml CHANGELOG.md CNAME CONTRIBUTING.md Gemfile Gemfile.lock Gruntfile.js ISSUE_TEMPLATE.md LICENSE _config.yml bower.json composer.json dist/ docs/ grunt/ js/ nuget/ package.js package.json sache.json scss/ nothing added to commit but untracked files present (use "git add" to track)
Here's how things stand now:
- Our working copy continues to have lots of untracked files and folders. However,
README.md
is not among them - Our staging area is empty
- Our git repo has 1 commit that added 1 file, which we can see if we use
git log
$ git log commit 03c95518ce08f59e850409a2d82bacad110151a1 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:07:09 2017 -0500 Added README file
Every record in our history is called a commit, and it's a snapshot of our repo's filesystem along with metadata:
- a unique commit identifier (SHA-1), in this case
03c95518ce08f59e850409a2d82bacad110151a1
, which is often shortened to the first 7 characters:03c9551
. - an author, every commit is done by somebody, and we want to keep track of this
- a date and time
- a commit message, describing what this commit changed, added, deleted, etc.
Step 4. other ways to add files
Let's add the rest of the files in our working directory to git. We can add more than one file at a time by calling git add
more than once:
$ git add package.js $ git add LICENSE $ git add Gemfile $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: Gemfile new file: LICENSE new file: package.js Untracked files: (use "git add <file>..." to include in what will be committed) .editorconfig .eslintignore .gitattributes .gitignore .hound.yml .houndignore .travis.yml CHANGELOG.md CNAME CONTRIBUTING.md Gemfile.lock Gruntfile.js ISSUE_TEMPLATE.md _config.yml bower.json composer.json dist/ docs/ grunt/ js/ nuget/ package.json sache.json scss/
We have 3 files in our staging area, which we can commit:
$ git commit -m "Added more files" [master 4ffa53b] Added more files 3 files changed, 49 insertions(+) create mode 100755 Gemfile create mode 100755 LICENSE create mode 100755 package.js
We can add multiple files in a single call to git add
as well:
$ git add Gemfile.lock Gruntfile.js ISSUE_TEMPLATE.md $ git commit -m "Added some more files" [master de3af0b] Added some more files 3 files changed, 435 insertions(+) create mode 100755 Gemfile.lock create mode 100755 Gruntfile.js create mode 100755 ISSUE_TEMPLATE.md
We can add files using a glob pattern, for example, all the *.json
files:
$ git add *.json $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: bower.json new file: composer.json new file: package.json new file: sache.json Untracked files: (use "git add <file>..." to include in what will be committed) .editorconfig .eslintignore .gitattributes .gitignore .hound.yml .houndignore .travis.yml CHANGELOG.md CNAME CONTRIBUTING.md _config.yml dist/ docs/ grunt/ js/ nuget/ scss/ $ git commit -m "Add *.json files" [master 5decfb3] Add *.json files 4 files changed, 189 insertions(+) create mode 100755 bower.json create mode 100755 composer.json create mode 100755 package.json create mode 100755 sache.json
We can add entire folders, too. For example, we can add the js/
folder, and everything within it:
$ git add js/ $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: js/.babelrc new file: js/.eslintrc.json new file: js/dist/alert.js new file: js/dist/alert.js.map new file: js/dist/button.js new file: js/dist/button.js.map new file: js/dist/carousel.js new file: js/dist/carousel.js.map new file: js/dist/collapse.js new file: js/dist/collapse.js.map new file: js/dist/dropdown.js new file: js/dist/dropdown.js.map new file: js/dist/modal.js new file: js/dist/modal.js.map new file: js/dist/popover.js new file: js/dist/popover.js.map new file: js/dist/scrollspy.js new file: js/dist/scrollspy.js.map new file: js/dist/tab.js new file: js/dist/tab.js.map new file: js/dist/tooltip.js new file: js/dist/tooltip.js.map new file: js/dist/util.js new file: js/dist/util.js.map new file: js/src/alert.js new file: js/src/button.js new file: js/src/carousel.js new file: js/src/collapse.js new file: js/src/dropdown.js new file: js/src/modal.js new file: js/src/popover.js new file: js/src/scrollspy.js new file: js/src/tab.js new file: js/src/tooltip.js new file: js/src/util.js new file: js/tests/.eslintrc.json new file: js/tests/README.md new file: js/tests/index.html new file: js/tests/unit/alert.js new file: js/tests/unit/button.js new file: js/tests/unit/carousel.js new file: js/tests/unit/collapse.js new file: js/tests/unit/dropdown.js new file: js/tests/unit/modal.js new file: js/tests/unit/phantom.js new file: js/tests/unit/popover.js new file: js/tests/unit/scrollspy.js new file: js/tests/unit/tab.js new file: js/tests/unit/tooltip.js new file: js/tests/vendor/qunit.css new file: js/tests/vendor/qunit.js new file: js/tests/visual/alert.html new file: js/tests/visual/button.html new file: js/tests/visual/carousel.html new file: js/tests/visual/collapse.html new file: js/tests/visual/dropdown.html new file: js/tests/visual/modal.html new file: js/tests/visual/popover.html new file: js/tests/visual/scrollspy.html new file: js/tests/visual/tab.html new file: js/tests/visual/tooltip.html Untracked files: (use "git add <file>..." to include in what will be committed) .editorconfig .eslintignore .gitattributes .gitignore .hound.yml .houndignore .travis.yml CHANGELOG.md CNAME CONTRIBUTING.md _config.yml dist/ docs/ grunt/ nuget/ scss/ $ git commit -m "Add js/ dir" [master 3679b53] Add js/ dir 61 files changed, 18240 insertions(+) create mode 100755 js/.babelrc create mode 100755 js/.eslintrc.json create mode 100755 js/dist/alert.js create mode 100755 js/dist/alert.js.map create mode 100755 js/dist/button.js create mode 100755 js/dist/button.js.map create mode 100755 js/dist/carousel.js create mode 100755 js/dist/carousel.js.map create mode 100755 js/dist/collapse.js create mode 100755 js/dist/collapse.js.map create mode 100755 js/dist/dropdown.js create mode 100755 js/dist/dropdown.js.map create mode 100755 js/dist/modal.js create mode 100755 js/dist/modal.js.map create mode 100755 js/dist/popover.js create mode 100755 js/dist/popover.js.map create mode 100755 js/dist/scrollspy.js create mode 100755 js/dist/scrollspy.js.map create mode 100755 js/dist/tab.js create mode 100755 js/dist/tab.js.map create mode 100755 js/dist/tooltip.js create mode 100755 js/dist/tooltip.js.map create mode 100755 js/dist/util.js create mode 100755 js/dist/util.js.map create mode 100755 js/src/alert.js create mode 100755 js/src/button.js create mode 100755 js/src/carousel.js create mode 100755 js/src/collapse.js create mode 100755 js/src/dropdown.js create mode 100755 js/src/modal.js create mode 100755 js/src/popover.js create mode 100755 js/src/scrollspy.js create mode 100755 js/src/tab.js create mode 100755 js/src/tooltip.js create mode 100755 js/src/util.js create mode 100755 js/tests/.eslintrc.json create mode 100755 js/tests/README.md create mode 100755 js/tests/index.html create mode 100755 js/tests/unit/alert.js create mode 100755 js/tests/unit/button.js create mode 100755 js/tests/unit/carousel.js create mode 100755 js/tests/unit/collapse.js create mode 100755 js/tests/unit/dropdown.js create mode 100755 js/tests/unit/modal.js create mode 100755 js/tests/unit/phantom.js create mode 100755 js/tests/unit/popover.js create mode 100755 js/tests/unit/scrollspy.js create mode 100755 js/tests/unit/tab.js create mode 100755 js/tests/unit/tooltip.js create mode 100755 js/tests/vendor/qunit.css create mode 100755 js/tests/vendor/qunit.js create mode 100755 js/tests/visual/alert.html create mode 100755 js/tests/visual/button.html create mode 100755 js/tests/visual/carousel.html create mode 100755 js/tests/visual/collapse.html create mode 100755 js/tests/visual/dropdown.html create mode 100755 js/tests/visual/modal.html create mode 100755 js/tests/visual/popover.html create mode 100755 js/tests/visual/scrollspy.html create mode 100755 js/tests/visual/tab.html create mode 100755 js/tests/visual/tooltip.html
Finally, we can add everything at once by passing the -A
flag. This is a dangerous thing to do unless you really, really mean to do it, since it will often add files you don't want. Use it sparringly! In this case it's useful, because we need to add everything else to our git history.
$ git add -A $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: .editorconfig new file: .eslintignore new file: .gitattributes new file: .gitignore new file: .hound.yml new file: .houndignore new file: .travis.yml new file: CHANGELOG.md new file: CNAME new file: CONTRIBUTING.md new file: _config.yml new file: dist/css/bootstrap-grid.css new file: dist/css/bootstrap-grid.css.map new file: dist/css/bootstrap-grid.min.css new file: dist/css/bootstrap-grid.min.css.map new file: dist/css/bootstrap-reboot.css new file: dist/css/bootstrap-reboot.css.map new file: dist/css/bootstrap-reboot.min.css new file: dist/css/bootstrap-reboot.min.css.map new file: dist/css/bootstrap.css new file: dist/css/bootstrap.css.map new file: dist/css/bootstrap.min.css new file: dist/css/bootstrap.min.css.map new file: dist/js/bootstrap.js new file: dist/js/bootstrap.min.js new file: docs/.htmlhintrc new file: docs/CNAME new file: docs/LICENSE new file: docs/_data/breakpoints.yml new file: docs/_data/browser-bugs.yml new file: docs/_data/browser-features.yml new file: docs/_data/core-team.yml new file: docs/_data/nav.yml new file: docs/_data/showcase.yml new file: docs/_data/translations.yml new file: docs/_includes/ads.html new file: docs/_includes/callout-warning-color-assistive-technologies.md new file: docs/_includes/footer.html new file: docs/_includes/header.html new file: docs/_includes/nav-docs.html new file: docs/_includes/nav-home.html new file: docs/_includes/page-headers.html new file: docs/_includes/social.html new file: docs/_layouts/default.html new file: docs/_layouts/docs.html new file: docs/_layouts/home.html new file: docs/_layouts/simple.html new file: docs/_plugins/bridge.rb new file: docs/_plugins/bugify.rb new file: docs/_plugins/callout.rb new file: docs/_plugins/highlight_alt.rb new file: docs/_plugins/markdown-block.rb new file: docs/about/brand.md new file: docs/about/history.md new file: docs/about/license.md new file: docs/about/team.md new file: docs/about/translations.md new file: docs/apple-touch-icon.png new file: docs/assets/brand/bootstrap-outline.svg new file: docs/assets/brand/bootstrap-punchout.svg new file: docs/assets/brand/bootstrap-social-logo.png new file: docs/assets/brand/bootstrap-social.png new file: docs/assets/brand/bootstrap-solid.svg new file: docs/assets/css/docs.min.css new file: docs/assets/css/docs.min.css.map new file: docs/assets/img/bs-themes.png new file: docs/assets/img/components.png new file: docs/assets/img/devices.png new file: docs/assets/img/expo-lyft.jpg new file: docs/assets/img/expo-newsweek.jpg new file: docs/assets/img/expo-riot.jpg new file: docs/assets/img/expo-vogue.jpg new file: docs/assets/img/sass.png new file: docs/assets/js/docs.min.js new file: docs/assets/js/ie-emulation-modes-warning.js new file: docs/assets/js/ie10-viewport-bug-workaround.js new file: docs/assets/js/src/application.js new file: docs/assets/js/vendor/anchor.min.js new file: docs/assets/js/vendor/clipboard.min.js new file: docs/assets/js/vendor/holder.min.js new file: docs/assets/js/vendor/jekyll-search.min.js new file: docs/assets/js/vendor/jquery-slim.min.js new file: docs/assets/js/vendor/tether.min.js new file: docs/assets/scss/_ads.scss new file: docs/assets/scss/_anchor.scss new file: docs/assets/scss/_booticon.scss new file: docs/assets/scss/_brand.scss new file: docs/assets/scss/_browser-bugs.scss new file: docs/assets/scss/_buttons.scss new file: docs/assets/scss/_callouts.scss new file: docs/assets/scss/_clipboard-js.scss new file: docs/assets/scss/_component-examples.scss new file: docs/assets/scss/_content.scss new file: docs/assets/scss/_examples.scss new file: docs/assets/scss/_featured-sites.scss new file: docs/assets/scss/_featurettes.scss new file: docs/assets/scss/_footer.scss new file: docs/assets/scss/_masthead.scss new file: docs/assets/scss/_nav.scss new file: docs/assets/scss/_page-header.scss new file: docs/assets/scss/_responsive-tests.scss new file: docs/assets/scss/_sidebar.scss new file: docs/assets/scss/_skiplink.scss new file: docs/assets/scss/_syntax.scss new file: docs/assets/scss/_team.scss new file: docs/assets/scss/docs.scss new file: docs/browser-bugs.md new file: docs/components/alerts.md new file: docs/components/badge.md new file: docs/components/breadcrumb.md new file: docs/components/button-group.md new file: docs/components/buttons.md new file: docs/components/card.md new file: docs/components/carousel.md new file: docs/components/collapse.md new file: docs/components/dropdowns.md new file: docs/components/forms.md new file: docs/components/input-group.md new file: docs/components/jumbotron.md new file: docs/components/list-group.md new file: docs/components/modal.md new file: docs/components/navbar.md new file: docs/components/navs.md new file: docs/components/pagination.md new file: docs/components/popovers.md new file: docs/components/progress.md new file: docs/components/scrollspy.md new file: docs/components/tooltips.md new file: docs/content/code.md new file: docs/content/figures.md new file: docs/content/images.md new file: docs/content/reboot.md new file: docs/content/tables.md new file: docs/content/typography.md new file: docs/dist/css/bootstrap-grid.css new file: docs/dist/css/bootstrap-grid.css.map new file: docs/dist/css/bootstrap-grid.min.css new file: docs/dist/css/bootstrap-grid.min.css.map new file: docs/dist/css/bootstrap-reboot.css new file: docs/dist/css/bootstrap-reboot.css.map new file: docs/dist/css/bootstrap-reboot.min.css new file: docs/dist/css/bootstrap-reboot.min.css.map new file: docs/dist/css/bootstrap.css new file: docs/dist/css/bootstrap.css.map new file: docs/dist/css/bootstrap.min.css new file: docs/dist/css/bootstrap.min.css.map new file: docs/dist/js/bootstrap.js new file: docs/dist/js/bootstrap.min.js new file: docs/examples/album/album.css new file: docs/examples/album/index.html new file: docs/examples/blog/blog.css new file: docs/examples/blog/index.html new file: docs/examples/carousel/carousel.css new file: docs/examples/carousel/index.html new file: docs/examples/cover/cover.css new file: docs/examples/cover/index.html new file: docs/examples/dashboard/dashboard.css new file: docs/examples/dashboard/index.html new file: docs/examples/grid/grid.css new file: docs/examples/grid/index.html new file: docs/examples/index.md new file: docs/examples/jumbotron/index.html new file: docs/examples/jumbotron/jumbotron.css new file: docs/examples/justified-nav/index.html new file: docs/examples/justified-nav/justified-nav.css new file: docs/examples/narrow-jumbotron/index.html new file: docs/examples/narrow-jumbotron/narrow-jumbotron.css new file: docs/examples/navbar-top-fixed/index.html new file: docs/examples/navbar-top-fixed/navbar-top-fixed.css new file: docs/examples/navbar-top/index.html new file: docs/examples/navbar-top/navbar-top.css new file: docs/examples/navbars/index.html new file: docs/examples/navbars/navbar.css new file: docs/examples/offcanvas/index.html new file: docs/examples/offcanvas/offcanvas.css new file: docs/examples/offcanvas/offcanvas.js new file: docs/examples/screenshots/album.jpg new file: docs/examples/screenshots/blog.jpg new file: docs/examples/screenshots/carousel.jpg new file: docs/examples/screenshots/cover.jpg new file: docs/examples/screenshots/dashboard.jpg new file: docs/examples/screenshots/equal-height-columns.jpg new file: docs/examples/screenshots/grid.jpg new file: docs/examples/screenshots/jumbotron-narrow.jpg new file: docs/examples/screenshots/jumbotron.jpg new file: docs/examples/screenshots/justified-nav.jpg new file: docs/examples/screenshots/navbar-fixed.jpg new file: docs/examples/screenshots/navbar-static.jpg new file: docs/examples/screenshots/navbar.jpg new file: docs/examples/screenshots/non-responsive.jpg new file: docs/examples/screenshots/offcanvas.jpg new file: docs/examples/screenshots/sign-in.jpg new file: docs/examples/screenshots/starter-template.jpg new file: docs/examples/screenshots/sticky-footer-navbar.jpg new file: docs/examples/screenshots/sticky-footer.jpg new file: docs/examples/screenshots/theme.jpg new file: docs/examples/signin/index.html new file: docs/examples/signin/signin.css new file: docs/examples/starter-template/index.html new file: docs/examples/starter-template/starter-template.css new file: docs/examples/sticky-footer-navbar/index.html new file: docs/examples/sticky-footer-navbar/sticky-footer-navbar.css new file: docs/examples/sticky-footer/index.html new file: docs/examples/sticky-footer/sticky-footer.css new file: docs/examples/tooltip-viewport/index.html new file: docs/examples/tooltip-viewport/tooltip-viewport.css new file: docs/examples/tooltip-viewport/tooltip-viewport.js new file: docs/extend/approach.md new file: docs/extend/icon-fonts.md new file: docs/extend/index.md new file: docs/favicon.ico new file: docs/getting-started/accessibility.md new file: docs/getting-started/best-practices.md new file: docs/getting-started/browsers-devices.md new file: docs/getting-started/build-tools.md new file: docs/getting-started/contents.md new file: docs/getting-started/download.md new file: docs/getting-started/introduction.md new file: docs/getting-started/javascript.md new file: docs/getting-started/options.md new file: docs/index.html new file: docs/layout/grid.md new file: docs/layout/media-object.md new file: docs/layout/overview.md new file: docs/layout/responsive-utilities.md new file: docs/migration.md new file: docs/robots.txt new file: docs/search.json new file: docs/utilities/borders.md new file: docs/utilities/clearfix.md new file: docs/utilities/close-icon.md new file: docs/utilities/colors.md new file: docs/utilities/display-property.md new file: docs/utilities/flexbox.md new file: docs/utilities/image-replacement.md new file: docs/utilities/invisible-content.md new file: docs/utilities/position.md new file: docs/utilities/responsive-helpers.md new file: docs/utilities/screenreaders.md new file: docs/utilities/sizing.md new file: docs/utilities/spacing.md new file: docs/utilities/typography.md new file: docs/utilities/vertical-align.md new file: grunt/change-version.js new file: grunt/configBridge.json new file: grunt/gcp-key.json.enc new file: grunt/npm-shrinkwrap.json new file: grunt/postcss.js new file: grunt/sauce_browsers.yml new file: grunt/upload-preview.sh new file: nuget/MyGet.ps1 new file: nuget/bootstrap.nuspec new file: nuget/bootstrap.sass.nuspec new file: scss/.scss-lint.yml new file: scss/_alert.scss new file: scss/_badge.scss new file: scss/_breadcrumb.scss new file: scss/_button-group.scss new file: scss/_buttons.scss new file: scss/_card.scss new file: scss/_carousel.scss new file: scss/_close.scss new file: scss/_code.scss new file: scss/_custom-forms.scss new file: scss/_custom.scss new file: scss/_dropdown.scss new file: scss/_forms.scss new file: scss/_grid.scss new file: scss/_images.scss new file: scss/_input-group.scss new file: scss/_jumbotron.scss new file: scss/_list-group.scss new file: scss/_media.scss new file: scss/_mixins.scss new file: scss/_modal.scss new file: scss/_nav.scss new file: scss/_navbar.scss new file: scss/_normalize.scss new file: scss/_pagination.scss new file: scss/_popover.scss new file: scss/_print.scss new file: scss/_progress.scss new file: scss/_reboot.scss new file: scss/_responsive-embed.scss new file: scss/_tables.scss new file: scss/_tooltip.scss new file: scss/_transitions.scss new file: scss/_type.scss new file: scss/_utilities.scss new file: scss/_variables.scss new file: scss/bootstrap-grid.scss new file: scss/bootstrap-reboot.scss new file: scss/bootstrap.scss new file: scss/mixins/_alert.scss new file: scss/mixins/_background-variant.scss new file: scss/mixins/_badge.scss new file: scss/mixins/_border-radius.scss new file: scss/mixins/_breakpoints.scss new file: scss/mixins/_buttons.scss new file: scss/mixins/_cards.scss new file: scss/mixins/_clearfix.scss new file: scss/mixins/_float.scss new file: scss/mixins/_forms.scss new file: scss/mixins/_gradients.scss new file: scss/mixins/_grid-framework.scss new file: scss/mixins/_grid.scss new file: scss/mixins/_hover.scss new file: scss/mixins/_image.scss new file: scss/mixins/_list-group.scss new file: scss/mixins/_lists.scss new file: scss/mixins/_nav-divider.scss new file: scss/mixins/_navbar-align.scss new file: scss/mixins/_pagination.scss new file: scss/mixins/_reset-text.scss new file: scss/mixins/_resize.scss new file: scss/mixins/_screen-reader.scss new file: scss/mixins/_size.scss new file: scss/mixins/_table-row.scss new file: scss/mixins/_text-emphasis.scss new file: scss/mixins/_text-hide.scss new file: scss/mixins/_text-truncate.scss new file: scss/mixins/_transforms.scss new file: scss/mixins/_visibility.scss new file: scss/utilities/_align.scss new file: scss/utilities/_background.scss new file: scss/utilities/_borders.scss new file: scss/utilities/_clearfix.scss new file: scss/utilities/_display.scss new file: scss/utilities/_flex.scss new file: scss/utilities/_float.scss new file: scss/utilities/_position.scss new file: scss/utilities/_screenreaders.scss new file: scss/utilities/_sizing.scss new file: scss/utilities/_spacing.scss new file: scss/utilities/_text.scss new file: scss/utilities/_visibility.scss $ git commit -m "Add everything else" [master e189bad] Add everything else 336 files changed, 60103 insertions(+) create mode 100755 .editorconfig create mode 100755 .eslintignore create mode 100755 .gitattributes create mode 100755 .gitignore create mode 100755 .hound.yml create mode 100755 .houndignore create mode 100755 .travis.yml create mode 100755 CHANGELOG.md create mode 100755 CNAME create mode 100755 CONTRIBUTING.md create mode 100755 _config.yml create mode 100755 dist/css/bootstrap-grid.css create mode 100755 dist/css/bootstrap-grid.css.map create mode 100755 dist/css/bootstrap-grid.min.css create mode 100755 dist/css/bootstrap-grid.min.css.map create mode 100755 dist/css/bootstrap-reboot.css create mode 100755 dist/css/bootstrap-reboot.css.map create mode 100755 dist/css/bootstrap-reboot.min.css create mode 100755 dist/css/bootstrap-reboot.min.css.map create mode 100755 dist/css/bootstrap.css create mode 100755 dist/css/bootstrap.css.map create mode 100755 dist/css/bootstrap.min.css create mode 100755 dist/css/bootstrap.min.css.map create mode 100755 dist/js/bootstrap.js create mode 100755 dist/js/bootstrap.min.js create mode 100755 docs/.htmlhintrc create mode 100755 docs/CNAME create mode 100755 docs/LICENSE create mode 100755 docs/_data/breakpoints.yml create mode 100755 docs/_data/browser-bugs.yml create mode 100755 docs/_data/browser-features.yml create mode 100755 docs/_data/core-team.yml create mode 100755 docs/_data/nav.yml create mode 100755 docs/_data/showcase.yml create mode 100755 docs/_data/translations.yml create mode 100755 docs/_includes/ads.html create mode 100755 docs/_includes/callout-warning-color-assistive-technologies.md create mode 100755 docs/_includes/footer.html create mode 100755 docs/_includes/header.html create mode 100755 docs/_includes/nav-docs.html create mode 100755 docs/_includes/nav-home.html create mode 100755 docs/_includes/page-headers.html create mode 100755 docs/_includes/social.html create mode 100755 docs/_layouts/default.html create mode 100755 docs/_layouts/docs.html create mode 100755 docs/_layouts/home.html create mode 100755 docs/_layouts/simple.html create mode 100755 docs/_plugins/bridge.rb create mode 100755 docs/_plugins/bugify.rb create mode 100755 docs/_plugins/callout.rb create mode 100755 docs/_plugins/highlight_alt.rb create mode 100755 docs/_plugins/markdown-block.rb create mode 100755 docs/about/brand.md create mode 100755 docs/about/history.md create mode 100755 docs/about/license.md create mode 100755 docs/about/team.md create mode 100755 docs/about/translations.md create mode 100755 docs/apple-touch-icon.png create mode 100755 docs/assets/brand/bootstrap-outline.svg create mode 100755 docs/assets/brand/bootstrap-punchout.svg create mode 100755 docs/assets/brand/bootstrap-social-logo.png create mode 100755 docs/assets/brand/bootstrap-social.png create mode 100755 docs/assets/brand/bootstrap-solid.svg create mode 100755 docs/assets/css/docs.min.css create mode 100755 docs/assets/css/docs.min.css.map create mode 100755 docs/assets/img/bs-themes.png create mode 100755 docs/assets/img/components.png create mode 100755 docs/assets/img/devices.png create mode 100755 docs/assets/img/expo-lyft.jpg create mode 100755 docs/assets/img/expo-newsweek.jpg create mode 100755 docs/assets/img/expo-riot.jpg create mode 100755 docs/assets/img/expo-vogue.jpg create mode 100755 docs/assets/img/sass.png create mode 100755 docs/assets/js/docs.min.js create mode 100755 docs/assets/js/ie-emulation-modes-warning.js create mode 100755 docs/assets/js/ie10-viewport-bug-workaround.js create mode 100755 docs/assets/js/src/application.js create mode 100755 docs/assets/js/vendor/anchor.min.js create mode 100755 docs/assets/js/vendor/clipboard.min.js create mode 100755 docs/assets/js/vendor/holder.min.js create mode 100755 docs/assets/js/vendor/jekyll-search.min.js create mode 100755 docs/assets/js/vendor/jquery-slim.min.js create mode 100755 docs/assets/js/vendor/tether.min.js create mode 100755 docs/assets/scss/_ads.scss create mode 100755 docs/assets/scss/_anchor.scss create mode 100755 docs/assets/scss/_booticon.scss create mode 100755 docs/assets/scss/_brand.scss create mode 100755 docs/assets/scss/_browser-bugs.scss create mode 100755 docs/assets/scss/_buttons.scss create mode 100755 docs/assets/scss/_callouts.scss create mode 100755 docs/assets/scss/_clipboard-js.scss create mode 100755 docs/assets/scss/_component-examples.scss create mode 100755 docs/assets/scss/_content.scss create mode 100755 docs/assets/scss/_examples.scss create mode 100755 docs/assets/scss/_featured-sites.scss create mode 100755 docs/assets/scss/_featurettes.scss create mode 100755 docs/assets/scss/_footer.scss create mode 100755 docs/assets/scss/_masthead.scss create mode 100755 docs/assets/scss/_nav.scss create mode 100755 docs/assets/scss/_page-header.scss create mode 100755 docs/assets/scss/_responsive-tests.scss create mode 100755 docs/assets/scss/_sidebar.scss create mode 100755 docs/assets/scss/_skiplink.scss create mode 100755 docs/assets/scss/_syntax.scss create mode 100755 docs/assets/scss/_team.scss create mode 100755 docs/assets/scss/docs.scss create mode 100755 docs/browser-bugs.md create mode 100755 docs/components/alerts.md create mode 100755 docs/components/badge.md create mode 100755 docs/components/breadcrumb.md create mode 100755 docs/components/button-group.md create mode 100755 docs/components/buttons.md create mode 100755 docs/components/card.md create mode 100755 docs/components/carousel.md create mode 100755 docs/components/collapse.md create mode 100755 docs/components/dropdowns.md create mode 100755 docs/components/forms.md create mode 100755 docs/components/input-group.md create mode 100755 docs/components/jumbotron.md create mode 100755 docs/components/list-group.md create mode 100755 docs/components/modal.md create mode 100755 docs/components/navbar.md create mode 100755 docs/components/navs.md create mode 100755 docs/components/pagination.md create mode 100755 docs/components/popovers.md create mode 100755 docs/components/progress.md create mode 100755 docs/components/scrollspy.md create mode 100755 docs/components/tooltips.md create mode 100755 docs/content/code.md create mode 100755 docs/content/figures.md create mode 100755 docs/content/images.md create mode 100755 docs/content/reboot.md create mode 100755 docs/content/tables.md create mode 100755 docs/content/typography.md create mode 100755 docs/dist/css/bootstrap-grid.css create mode 100755 docs/dist/css/bootstrap-grid.css.map create mode 100755 docs/dist/css/bootstrap-grid.min.css create mode 100755 docs/dist/css/bootstrap-grid.min.css.map create mode 100755 docs/dist/css/bootstrap-reboot.css create mode 100755 docs/dist/css/bootstrap-reboot.css.map create mode 100755 docs/dist/css/bootstrap-reboot.min.css create mode 100755 docs/dist/css/bootstrap-reboot.min.css.map create mode 100755 docs/dist/css/bootstrap.css create mode 100755 docs/dist/css/bootstrap.css.map create mode 100755 docs/dist/css/bootstrap.min.css create mode 100755 docs/dist/css/bootstrap.min.css.map create mode 100755 docs/dist/js/bootstrap.js create mode 100755 docs/dist/js/bootstrap.min.js create mode 100755 docs/examples/album/album.css create mode 100755 docs/examples/album/index.html create mode 100755 docs/examples/blog/blog.css create mode 100755 docs/examples/blog/index.html create mode 100755 docs/examples/carousel/carousel.css create mode 100755 docs/examples/carousel/index.html create mode 100755 docs/examples/cover/cover.css create mode 100755 docs/examples/cover/index.html create mode 100755 docs/examples/dashboard/dashboard.css create mode 100755 docs/examples/dashboard/index.html create mode 100755 docs/examples/grid/grid.css create mode 100755 docs/examples/grid/index.html create mode 100755 docs/examples/index.md create mode 100755 docs/examples/jumbotron/index.html create mode 100755 docs/examples/jumbotron/jumbotron.css create mode 100755 docs/examples/justified-nav/index.html create mode 100755 docs/examples/justified-nav/justified-nav.css create mode 100755 docs/examples/narrow-jumbotron/index.html create mode 100755 docs/examples/narrow-jumbotron/narrow-jumbotron.css create mode 100755 docs/examples/navbar-top-fixed/index.html create mode 100755 docs/examples/navbar-top-fixed/navbar-top-fixed.css create mode 100755 docs/examples/navbar-top/index.html create mode 100755 docs/examples/navbar-top/navbar-top.css create mode 100755 docs/examples/navbars/index.html create mode 100755 docs/examples/navbars/navbar.css create mode 100755 docs/examples/offcanvas/index.html create mode 100755 docs/examples/offcanvas/offcanvas.css create mode 100755 docs/examples/offcanvas/offcanvas.js create mode 100755 docs/examples/screenshots/album.jpg create mode 100755 docs/examples/screenshots/blog.jpg create mode 100755 docs/examples/screenshots/carousel.jpg create mode 100755 docs/examples/screenshots/cover.jpg create mode 100755 docs/examples/screenshots/dashboard.jpg create mode 100755 docs/examples/screenshots/equal-height-columns.jpg create mode 100755 docs/examples/screenshots/grid.jpg create mode 100755 docs/examples/screenshots/jumbotron-narrow.jpg create mode 100755 docs/examples/screenshots/jumbotron.jpg create mode 100755 docs/examples/screenshots/justified-nav.jpg create mode 100755 docs/examples/screenshots/navbar-fixed.jpg create mode 100755 docs/examples/screenshots/navbar-static.jpg create mode 100755 docs/examples/screenshots/navbar.jpg create mode 100755 docs/examples/screenshots/non-responsive.jpg create mode 100755 docs/examples/screenshots/offcanvas.jpg create mode 100755 docs/examples/screenshots/sign-in.jpg create mode 100755 docs/examples/screenshots/starter-template.jpg create mode 100755 docs/examples/screenshots/sticky-footer-navbar.jpg create mode 100755 docs/examples/screenshots/sticky-footer.jpg create mode 100755 docs/examples/screenshots/theme.jpg create mode 100755 docs/examples/signin/index.html create mode 100755 docs/examples/signin/signin.css create mode 100755 docs/examples/starter-template/index.html create mode 100755 docs/examples/starter-template/starter-template.css create mode 100755 docs/examples/sticky-footer-navbar/index.html create mode 100755 docs/examples/sticky-footer-navbar/sticky-footer-navbar.css create mode 100755 docs/examples/sticky-footer/index.html create mode 100755 docs/examples/sticky-footer/sticky-footer.css create mode 100755 docs/examples/tooltip-viewport/index.html create mode 100755 docs/examples/tooltip-viewport/tooltip-viewport.css create mode 100755 docs/examples/tooltip-viewport/tooltip-viewport.js create mode 100755 docs/extend/approach.md create mode 100755 docs/extend/icon-fonts.md create mode 100755 docs/extend/index.md create mode 100755 docs/favicon.ico create mode 100755 docs/getting-started/accessibility.md create mode 100755 docs/getting-started/best-practices.md create mode 100755 docs/getting-started/browsers-devices.md create mode 100755 docs/getting-started/build-tools.md create mode 100755 docs/getting-started/contents.md create mode 100755 docs/getting-started/download.md create mode 100755 docs/getting-started/introduction.md create mode 100755 docs/getting-started/javascript.md create mode 100755 docs/getting-started/options.md create mode 100755 docs/index.html create mode 100755 docs/layout/grid.md create mode 100755 docs/layout/media-object.md create mode 100755 docs/layout/overview.md create mode 100755 docs/layout/responsive-utilities.md create mode 100755 docs/migration.md create mode 100755 docs/robots.txt create mode 100755 docs/search.json create mode 100755 docs/utilities/borders.md create mode 100755 docs/utilities/clearfix.md create mode 100755 docs/utilities/close-icon.md create mode 100755 docs/utilities/colors.md create mode 100755 docs/utilities/display-property.md create mode 100755 docs/utilities/flexbox.md create mode 100755 docs/utilities/image-replacement.md create mode 100755 docs/utilities/invisible-content.md create mode 100755 docs/utilities/position.md create mode 100755 docs/utilities/responsive-helpers.md create mode 100755 docs/utilities/screenreaders.md create mode 100755 docs/utilities/sizing.md create mode 100755 docs/utilities/spacing.md create mode 100755 docs/utilities/typography.md create mode 100755 docs/utilities/vertical-align.md create mode 100755 grunt/change-version.js create mode 100755 grunt/configBridge.json create mode 100755 grunt/gcp-key.json.enc create mode 100755 grunt/npm-shrinkwrap.json create mode 100755 grunt/postcss.js create mode 100755 grunt/sauce_browsers.yml create mode 100755 grunt/upload-preview.sh create mode 100755 nuget/MyGet.ps1 create mode 100755 nuget/bootstrap.nuspec create mode 100755 nuget/bootstrap.sass.nuspec create mode 100755 scss/.scss-lint.yml create mode 100755 scss/_alert.scss create mode 100755 scss/_badge.scss create mode 100755 scss/_breadcrumb.scss create mode 100755 scss/_button-group.scss create mode 100755 scss/_buttons.scss create mode 100755 scss/_card.scss create mode 100755 scss/_carousel.scss create mode 100755 scss/_close.scss create mode 100755 scss/_code.scss create mode 100755 scss/_custom-forms.scss create mode 100755 scss/_custom.scss create mode 100755 scss/_dropdown.scss create mode 100755 scss/_forms.scss create mode 100755 scss/_grid.scss create mode 100755 scss/_images.scss create mode 100755 scss/_input-group.scss create mode 100755 scss/_jumbotron.scss create mode 100755 scss/_list-group.scss create mode 100755 scss/_media.scss create mode 100755 scss/_mixins.scss create mode 100755 scss/_modal.scss create mode 100755 scss/_nav.scss create mode 100755 scss/_navbar.scss create mode 100755 scss/_normalize.scss create mode 100755 scss/_pagination.scss create mode 100755 scss/_popover.scss create mode 100755 scss/_print.scss create mode 100755 scss/_progress.scss create mode 100755 scss/_reboot.scss create mode 100755 scss/_responsive-embed.scss create mode 100755 scss/_tables.scss create mode 100755 scss/_tooltip.scss create mode 100755 scss/_transitions.scss create mode 100755 scss/_type.scss create mode 100755 scss/_utilities.scss create mode 100755 scss/_variables.scss create mode 100755 scss/bootstrap-grid.scss create mode 100755 scss/bootstrap-reboot.scss create mode 100755 scss/bootstrap.scss create mode 100755 scss/mixins/_alert.scss create mode 100755 scss/mixins/_background-variant.scss create mode 100755 scss/mixins/_badge.scss create mode 100755 scss/mixins/_border-radius.scss create mode 100755 scss/mixins/_breakpoints.scss create mode 100755 scss/mixins/_buttons.scss create mode 100755 scss/mixins/_cards.scss create mode 100755 scss/mixins/_clearfix.scss create mode 100755 scss/mixins/_float.scss create mode 100755 scss/mixins/_forms.scss create mode 100755 scss/mixins/_gradients.scss create mode 100755 scss/mixins/_grid-framework.scss create mode 100755 scss/mixins/_grid.scss create mode 100755 scss/mixins/_hover.scss create mode 100755 scss/mixins/_image.scss create mode 100755 scss/mixins/_list-group.scss create mode 100755 scss/mixins/_lists.scss create mode 100755 scss/mixins/_nav-divider.scss create mode 100755 scss/mixins/_navbar-align.scss create mode 100755 scss/mixins/_pagination.scss create mode 100755 scss/mixins/_reset-text.scss create mode 100755 scss/mixins/_resize.scss create mode 100755 scss/mixins/_screen-reader.scss create mode 100755 scss/mixins/_size.scss create mode 100755 scss/mixins/_table-row.scss create mode 100755 scss/mixins/_text-emphasis.scss create mode 100755 scss/mixins/_text-hide.scss create mode 100755 scss/mixins/_text-truncate.scss create mode 100755 scss/mixins/_transforms.scss create mode 100755 scss/mixins/_visibility.scss create mode 100755 scss/utilities/_align.scss create mode 100755 scss/utilities/_background.scss create mode 100755 scss/utilities/_borders.scss create mode 100755 scss/utilities/_clearfix.scss create mode 100755 scss/utilities/_display.scss create mode 100755 scss/utilities/_flex.scss create mode 100755 scss/utilities/_float.scss create mode 100755 scss/utilities/_position.scss create mode 100755 scss/utilities/_screenreaders.scss create mode 100755 scss/utilities/_sizing.scss create mode 100755 scss/utilities/_spacing.scss create mode 100755 scss/utilities/_text.scss create mode 100755 scss/utilities/_visibility.scss
If we inspect our repo's history again, we'll see all of the commits we just made:
$ git log commit e189bada7f9e77e8717cada46fa7cd05d6103172 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:39:35 2017 -0500 Add everything else commit 3679b53441a4df21b06875ed0bf4e286ecfd13a7 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:37:00 2017 -0500 Add js/ dir commit 5decfb341f6d9780053a4416d8adcf09a7b5b349 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:34:00 2017 -0500 Add *.json files commit de3af0b5e829047495043779d2d9d65a85e611f9 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:31:47 2017 -0500 Added some more files commit 4ffa53b8304a4f64e998217a1f1e07ccb300ede5 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:30:16 2017 -0500 Added more files commit 03c95518ce08f59e850409a2d82bacad110151a1 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:07:09 2017 -0500 Added README file
Step 5: updating an existing tracked file
So far we've only added new files. Once a file is being tracked by git, we can also make changes to it, and record that change. The process is very similar to adding a new file: both methods involve staging a new snapshot of our repo's files and committing it.
Let's make a change to docs/index.html
and record it in our git history.
First, open docs/index.html
in your favourite editor and let's change the wording in the beginning of the file slightly. We'll change Bootstrap is the most popular...
to Bootstrap is an amazing...
:
Before | After |
---|---|
--- layout: home --- <main class="bd-masthead" id="content"> <div class="container"> <span class="bd-booticon outline">B</span> <p class="lead">Bootstrap is the most popular HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> |
--- layout: home --- <main class="bd-masthead" id="content"> <div class="container"> <span class="bd-booticon outline">B</span> <p class="lead">Bootstrap is an amazing HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> |
Save the file and let's check our repo's status:
$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: docs/index.html no changes added to commit (use "git add" and/or "git commit -a")
Here git reports that one of our tracked files has Changes not staged for commit. In other words, it sees that the version of docs/index.html
in our Working Directory differs from what is in the last commit.
Git sees changes on a per-line basis to our files. We can ask git to show us what's changed by using git diff
:
$ git diff diff --git a/docs/index.html b/docs/index.html index b762da7..f43edfa 100755 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ layout: home <main class="bd-masthead" id="content"> <div class="container"> <span class="bd-booticon outline">B</span> - <p class="lead">Bootstrap is the most popular HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> + <p class="lead">Bootstrap is an amazing HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> <p class="lead"> <a href="{{ site.baseurl }}/getting-started/download/" class="btn btn-lg" onclick="ga('send', 'event', 'Jumbotron actions', 'Download', 'Download {{ site.current_version }}');">Download Bootstrap</a> </p>
This diff
tells us a few things:
- the file
docs/index.html
changed - the change to this file starts at line 5 in the original, and we have 7 lines of context
- the actual line that changed is shown with a delete (
-
) followed by an addition (+
)
Let's commit this change. Just like we did when we first added this file, we'll git add
then git commit
:
$ git add docs/index.html $ git commit -m "Update language in docs/index.html" [master e26ed85] Update language in docs/index.html 1 file changed, 1 insertion(+), 1 deletion(-)
We can review this commit by using git show [commit sha]
. If we don't specify a particular commit sha to show, git will show us the last commit (aka, HEAD
):
commit e26ed85fd69e11c8b4325617bdba3fad9746f99e Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 15:41:01 2017 -0500 Update language in docs/index.html diff --git a/docs/index.html b/docs/index.html index b762da7..f43edfa 100755 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ layout: home <main class="bd-masthead" id="content"> <div class="container"> <span class="bd-booticon outline">B</span> - <p class="lead">Bootstrap is the most popular HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> + <p class="lead">Bootstrap is an amazing HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> <p class="lead"> <a href="{{ site.baseurl }}/getting-started/download/" class="btn btn-lg" onclick="ga('send', 'event', 'Jumbotron actions', 'Download', 'Download {{ site.current_version }}');">Download Bootstrap</a> </p>
You can also ask git to show you changes in the log by adding the -p
flag (i.e., "show patch"):
$ git log -p commit e26ed85fd69e11c8b4325617bdba3fad9746f99e Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 15:41:01 2017 -0500 Update language in docs/index.html diff --git a/docs/index.html b/docs/index.html index b762da7..f43edfa 100755 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ layout: home <main class="bd-masthead" id="content"> <div class="container"> <span class="bd-booticon outline">B</span> - <p class="lead">Bootstrap is the most popular HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> + <p class="lead">Bootstrap is an amazing HTML, CSS, and JS framework in the world for building responsive, mobile-first projects on the web.</p> <p class="lead"> <a href="{{ site.baseurl }}/getting-started/download/" class="btn btn-lg" onclick="ga('send', 'event', 'Jumbotron actions', 'Download', 'Download {{ site.current_version }}');">Download Bootstrap</a> </p> commit e189bada7f9e77e8717cada46fa7cd05d6103172 Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 11:39:35 2017 -0500 Add everything else ...
Step 6: moving and removing files
We want to record every change we make to our files. This includes adding new files, making changes to those files, but also renaming, moving, and deleting. Every action we make with our code is something we want to record in git, something we want to be able to go back and examine or maybe undo.
Git makes it easy to do all of this, by adding its own versions of common Unix file commands:
-
git mv
- move or rename a file or directory -
git rm
- remove files from the working directory and index
Let's try them both. First, we'll delete a file, then examine our repo's status:
$ git rm CHANGELOG.md rm 'CHANGELOG.md' $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: CHANGELOG.md
Here we've staged a delete, but we still have to commit it, just like when we add a file:
$ git commit -m "Remove CHANGELOG" [master 7c16e80] Remove CHANGELOG 1 file changed, 5 deletions(-) delete mode 100755 CHANGELOG.md
The file is now removed from our working directory, and a snapshot of our code without that file has been added to the history. The file still exists in the older snapshots, if we ever want to get it back (see below).
If you need to recursively remove files under a directory, you can pass the -r
(i.e., Recursive) flag:
$ git commit -m "Rename LICENSE" [master 437bd08] Rename LICENSE 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE.txt (100%) $ git rm -r dist/ rm 'dist/css/bootstrap-grid.css' rm 'dist/css/bootstrap-grid.css.map' rm 'dist/css/bootstrap-grid.min.css' rm 'dist/css/bootstrap-grid.min.css.map' rm 'dist/css/bootstrap-reboot.css' rm 'dist/css/bootstrap-reboot.css.map' rm 'dist/css/bootstrap-reboot.min.css' rm 'dist/css/bootstrap-reboot.min.css.map' rm 'dist/css/bootstrap.css' rm 'dist/css/bootstrap.css.map' rm 'dist/css/bootstrap.min.css' rm 'dist/css/bootstrap.min.css.map' rm 'dist/js/bootstrap.js' rm 'dist/js/bootstrap.min.js' $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: dist/css/bootstrap-grid.css deleted: dist/css/bootstrap-grid.css.map deleted: dist/css/bootstrap-grid.min.css deleted: dist/css/bootstrap-grid.min.css.map deleted: dist/css/bootstrap-reboot.css deleted: dist/css/bootstrap-reboot.css.map deleted: dist/css/bootstrap-reboot.min.css deleted: dist/css/bootstrap-reboot.min.css.map deleted: dist/css/bootstrap.css deleted: dist/css/bootstrap.css.map deleted: dist/css/bootstrap.min.css deleted: dist/css/bootstrap.min.css.map deleted: dist/js/bootstrap.js deleted: dist/js/bootstrap.min.js $ git commit -m "Delete dist/" [master 6ec7cbc] Delete dist/ 14 files changed, 14668 deletions(-) delete mode 100755 dist/css/bootstrap-grid.css delete mode 100755 dist/css/bootstrap-grid.css.map delete mode 100755 dist/css/bootstrap-grid.min.css delete mode 100755 dist/css/bootstrap-grid.min.css.map delete mode 100755 dist/css/bootstrap-reboot.css delete mode 100755 dist/css/bootstrap-reboot.css.map delete mode 100755 dist/css/bootstrap-reboot.min.css delete mode 100755 dist/css/bootstrap-reboot.min.css.map delete mode 100755 dist/css/bootstrap.css delete mode 100755 dist/css/bootstrap.css.map delete mode 100755 dist/css/bootstrap.min.css delete mode 100755 dist/css/bootstrap.min.css.map delete mode 100755 dist/js/bootstrap.js delete mode 100755 dist/js/bootstrap.min.js
Moving and renaming a file are just as easy, and both use the git mv
command. Let's add a .txt
extension to the LICENSE
file, and commit the change:
$ git mv LICENSE LICENSE.txt $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: LICENSE -> LICENSE.txt $ git commit -m "Rename LICENSE" [master 437bd08] Rename LICENSE 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE.txt (100%)
Telling git about the changes to a file's name or path means that it can track changes to the file contents even when it moves (i.e., git will know that LICENSE
and LICENSE.txt
represent the same thing in the history)
Step 7: fixing common mistakes
A common issue we all run into is committing a change, then realizing we made a mistake or forgot to include a related change. It's fine to just commit again, but what if you made a typo in your commit message or left something out that really should have been included?
We can amend our previous commit instead of making a new one easily. Let's see it in action.
First, let's make a change to docs/_includes/callout-warning-color-assistive-technologies.md
, which changes color to colour:
Before | After |
---|---|
{% callout warning %} #### Conveying meaning to assistive technologies Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. |
{% callout warning %} #### Conveying meaning to assistive technologies Using colour to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. |
We can stage this change and commit:
$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: docs/_includes/callout-warning-color-assistive-technologies.md no changes added to commit (use "git add" and/or "git commit -a") $ git add docs/_includes/callout-warning-color-assistive-technologies.md $ git commit -m "Switch color to colour in docs/_includes/callout-warning-color-assistive-technologies.md" [master 1e9d17d] Switch color to colour in docs/_includes/callout-warning-color-assistive-technologies.md 1 file changed, 5 insertions(+), 5 deletions(-) rewrite docs/_includes/callout-warning-color-assistive-technologies.md (84%)
Later we discover that there are actually 2 occurances of color in that file, and we only changed the first one. Let's fix that and alter our commit using the --amend
flag.
First, re-open the docs/_includes/callout-warning-color-assistive-technologies.md
file in your editor, and correct the second color to colour. Then we can add and re-commit:
$ git add docs/_includes/callout-warning-color-assistive-technologies.md $ git commit --amend --no-edit
NOTE: you can also use this method to fix a typo in your commit message, just leave off the --no-edit
flag. Doing so will cause git to open your editor and let you edit your previous commit message. If you like it as is, just save the file and exit.
After amending my commit, I can git show
the commit and prove to myself that both uses of color have in fact been changed:
commit 88f1a8976d7d7d6a031d1e8fe9c212a5a357650e Author: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca> Date: Wed Jan 11 16:14:17 2017 -0500 Switch color to colour in docs/_includes/callout-warning-color-assistive-technologies.md diff --git a/docs/_includes/callout-warning-color-assistive-technologies.md b/docs/_includes/callout-warning-color-assistive-technologies.md index b92a1c3..c1a4533 100755 --- a/docs/_includes/callout-warning-color-assistive-technologies.md +++ b/docs/_includes/callout-warning-color-assistive-technologies.md @@ -1,5 +1,5 @@ {% callout warning %} #### Conveying meaning to assistive technologies -Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the `.sr-only` class. +Using colour to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the colour is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the `.sr-only` class. {% endcallout %} \ No newline at end of file
Another common scenario that happens is accidentally staging changes to files that you didn't mean to add. For example, you might be testing a fix you've made, and need to hard-code a filename in another file to see if it works. Once you know it's working, you want to commit the fix but not your testing code. People often get into this problem when they add too much at once, for example git add *
. This will work, but it adds everything that's different in your working directory.
Let's modify two files, CONTRIBUTING.md
and README.md
. I've made two small modifications, replacing one word in each file. Here's my repo's status and diff:
$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: CONTRIBUTING.md modified: README.md no changes added to commit (use "git add" and/or "git commit -a") $ git diff diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a0745d7..ffcd657 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ process easy and effective for everyone involved. Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, -they should reciprocate that respect in addressing your issue or assessing +they should reciprocate that respect in addressing your issue or reviewing patches and features. diff --git a/README.md b/README.md index a8a2c26..27f324b 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Selenium Test Status](https://saucelabs.com/browser-matrix/bootstrap.svg)](https://saucelabs.com/u/bootstrap) -Bootstrap is a sleek, intuitive, and powerful front-end framework for faster and easier web development, created by [Mark Otto](https://twitter.com/mdo) and [Jacob Thornton](https://twitter.com/fat), and maintained by the [core team](https://github.com/orgs/twbs/people) with the massive support and involvement of the community. +Bootstrap is a fun, intuitive, and powerful front-end framework for faster and easier web development, created by [Mark Otto](https://twitter.com/mdo) and [Jacob Thornton](https://twitter.com/fat), and maintained by the [core team](https://github.com/orgs/twbs/people) with the massive support and involvement of the community. To get started, check out <https://getbootstrap.com>!
Let's "accidentally" add all changed files at once (i.e., use *
instead of individual filenames):
$ git add * $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: CONTRIBUTING.md modified: README.md
What if I didn't mean to include the change to CONTRIBUTING.md
in this commit? Git helpfully tells me what to do: use "git reset HEAD <file>..." to unstage
. This means to reset what you have in the staging area for the given file with what was in the last commit (the HEAD
), essentially undoing your last staged changes. Let's try it!
$ git reset HEAD CONTRIBUTING.md Unstaged changes after reset: M CONTRIBUTING.md $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: README.md Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: CONTRIBUTING.md
My changes to CONTRIBUTING.md
are still present in my working directory, but they are no longer staged as part of this commit.
I could go one step further and ask git to "undo" all changes to CONTRIBUTING.md
in my working directory. This is more destructive than what we did above, since it means rewriting the file exactly as it was in the last commit. But, when you want to get back to a known-good state, it's an easy way to correct things.
$ git checkout -- CONTRIBUTING.md $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: README.md
Now the changes I made to CONTRIBUTING.md
are gone, and the last-known version of that file is what is in my working directory once more.
In the second git walk-through, we'll look at how git enables distributed workflows.