CINXE.COM

Git - Staging Area

<!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript"> const currentTheme = localStorage.getItem("theme") if (currentTheme) { const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches if ((prefersDarkScheme && currentTheme === "light") || (!prefersDarkScheme && currentTheme === "dark")) { document.documentElement.dataset.theme = currentTheme } } </script> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - Staging Area</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> </head> <body id="about"> <div class="inner"> <header> <a id="logo" href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" class="no-filter" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <div id="search-container"> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </div> <img src="/images/dark-mode.svg" id="dark-mode-button" /> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about" class="active">About</a> <ul class="expanded"> <li> <a href="/about/branching-and-merging">Branching and Merging</a> </li> <li> <a href="/about/small-and-fast">Small and Fast</a> </li> <li> <a href="/about/distributed">Distributed</a> </li> <li> <a href="/about/data-assurance">Data Assurance</a> </li> <li> <a href="/about/staging-area" class="active">Staging Area</a> </li> <li> <a href="/about/free-and-open-source">Free and Open Source</a> </li> <li> <a href="/about/trademark">Trademark</a> </li> </ul> </li> <li> <a href="/doc">Documentation</a> <ul > <li> <a href="/docs">Reference</a> </li> <li> <a href="/book">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> <hr class="sidebar"> <div class="callout"> <p>The entire <strong><a href="/book">Pro Git book</a></strong> written by Scott Chacon and Ben Straub is available to <a href="/book">read online for free</a>. Dead tree versions are available on <a href="https://www.amazon.com/Pro-Git-Scott-Chacon/dp/1484200772?ie=UTF8&camp=1789&creative=9325&creativeASIN=1430218339&linkCode=as2&tag=git-sfconservancy-20">Amazon.com</a>. </p> </div> </nav> </aside> <div id="content" data-pagefind-filter="category:about" data-pagefind-weight="0.05" data-pagefind-body> <div id="main"> <h1 data-pagefind-meta="title">About - Staging Area</h1> <ol id="about-nav"> <li> <a href="/about/branching-and-merging" class="three-line">Branching and Merging</a> </li> <li> <a href="/about/small-and-fast" class="two-line">Small and Fast</a> </li> <li> <a href="/about/distributed" class="one-line">Distributed</a> </li> <li> <a href="/about/data-assurance" class="two-line">Data Assurance</a> </li> <li> <a href="/about/staging-area" class="two-line current">Staging Area</a> </li> <li> <a href="/about/free-and-open-source" class="three-line">Free and Open Source</a> </li> <li> <a href="/about/trademark" class="one-line">Trademark</a> </li> </ol> <section class="about" id="staging-area"> <h2>Staging Area</h2> <p> Unlike the other systems, Git has something called the "staging area" or "index". This is an intermediate area where commits can be formatted and reviewed before completing the commit. </p> <p> One thing that sets Git apart from other tools is that it's possible to quickly stage some of your files and commit them without committing all of the other modified files in your working directory or having to list them on the command line during the commit. </p> <p class="center"> <img src="/images/about/index1@2x.png" width="336" height="194" alt="Index 1"> </p> <p> This allows you to stage only portions of a modified file. Gone are the days of making two logically unrelated modifications to a file before you realized that you forgot to commit one of them. Now you can just stage the change you need for the current commit and stage the other change for the next commit. This feature scales up to as many different changes to your file as needed. </p> <p> Of course, Git also makes it easy to ignore this feature if you don't want that kind of control — just add a '-a' to your commit command in order to add all changes to all files to the staging area. </p> <p class="center"> <img src="/images/about/index2@2x.png" width="338" height="185" alt="Index 2"> </p> <div class="bottom-nav" style="display: block;"> <a href="/about/data-assurance" class="previous" data-section-id="info-assurance">← Data Assurance</a> <a href="/about/free-and-open-source" class="next" data-section-id="free-and-open-source">Free and Open Source →</a> </div> </section> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> <script src="/js/application.min.js"></script> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10