You should make new commits often, based around logical units of change. Over time, commits should tell a story of the history of your repository and how it came to be the way that it currently is.
Commits include lots of metadata in addition to the contents and message, like the author, timestamp, and more. By using commits, you're able to craft history intentionally and safely. You can make commits to different branches, and specify exactly what changes you want to include. Commits are created on the branch that you're currently checked out to wherever HEAD is pointing so it's always a good idea to run git status before making a commit, to check that you're checked-out to the branch that you intend to be.
Before you commit, you will need to stage any new changes that you'd like to include in the commit using git add [file]. Commits are lightweight SHA hashes, objects within Git. As long as you're working with text files, you won't need to worry about how many files you have, how big they are, or how many commits you make. Git can handle it!
Commits have two phases to help you craft commits properly. Commits should be logical, atomic units of change that represent a specific idea. But, not all humans work that way. You may get carried away and end up solving two or three problems before you remember to commit!
That's OK - Git can handle that. Without adding any files, the command git commit won't work. Git only looks to the staging area to find out what to commit. Staging, or adding, files, is possible through the command line, and also possible with most Git interfaces like GitHub Desktop by selecting the lines or files that you'd like to stage. You can also use a handy command, git add -p , to walk through the changes and separate them out, even if they're in the same file.
To see all of the possible options you have with git commit , check out Git's documentation. Sometimes, you may need to change history. For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call:.
The last really useful option to pass to git log as a filter is a path. If you specify a directory or file name, you can limit the log output to commits that introduced a change to those files. This is always the last option and is generally preceded by double dashes -- to separate the paths from the options:. For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano in the month of October and are not merge commits, you can run something like this:.
Of the nearly 40, commits in the Git source code history, this command shows the 6 that match those criteria. To prevent the display of merge commits cluttering up your log history, simply add the log option --no-merges.
Getting Started 1. Git Basics 2. Git Branching 3. Git on the Server 4. Distributed Git 5. GitHub 6. Git Tools 7. Customizing Git 8.
Git and Other Systems 9. Git Internals Appendix C: Git Commands A3. To get the project, run:. Aug 16, Prepare for release.
Oct 22, Tighter and consistent wording. Apr 24, Add support for opt-in download to exec and run Sep 10, Use https instead of http Jul 15, Add test folder and tests. May 4, Apr 7, Aug 8, Remove leading line break in Makefile. Dec 28, Rework install location description.
Sep 25, View code. Installation If you already have Node. About Node version management Resources Readme. MIT License. Releases 48 8.
0コメント