-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start VCS lecture 3 #45
Open
tchebb
wants to merge
5
commits into
main
Choose a base branch
from
tom-vcs-lecture3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2138,8 +2138,58 @@ CONTENTS: More complex workflows | |
|
||
### Branches | ||
|
||
TODO: "What is a branch?" paragraph. A convenient name you can use to reference | ||
a specific variant of your code or set of changes you're working on. | ||
Although we've mentioned them several times, we've yet to explain what | ||
*branches* actually are. Conceptually, a branch is one specific thread of | ||
development---in other words, a specific commit history---within a Git | ||
repository. Newly-created repositories have just a single branch, conventionally | ||
named either `main` or `master` (which, save for being automatically created, is | ||
identical to any other branch). So far we have only added commits to this | ||
branch. | ||
|
||
By creating other branches, you can keep track of more than just one history. | ||
One branch, for example, might be an old version of the project, lacking new | ||
commits from `main`. Another might contain everything from `main` plus | ||
additional commits pertaining to an in-development feature. And yet another | ||
might have no commits in common with `main` and hold a completely separate | ||
codebase (although this is not common---typically branches within a single | ||
repository share at least some commits). | ||
|
||
Every branch has a name, which is by convention lowercase with hyphens (`-`) | ||
between words. Depending on where you use it, a branch's name may refer either | ||
to the branch itself or to the latest commit made to that branch---for example, | ||
if you pass a branch name to a command that expects a revision parameter, like | ||
`git show`: | ||
|
||
```console?prompt=$ | ||
$ git show -s main | ||
commit 0fb52357b6d1c76bda2d33890e1c8d2cd36ec792 (HEAD -> main) | ||
Author: Thomas Hebb <[email protected]> | ||
Date: Wed Feb 28 22:35:12 2024 -0500 | ||
|
||
Revert "Support the modulo operator" | ||
|
||
This reverts commit 2d6603026105b168c126d2ee22c6f4dba8d48437. | ||
$ | ||
``` | ||
|
||
Note the annotation, `(HEAD -> main)`, that Git added to this commit. It tells | ||
us two things: firstly, that this commit is the most recent commit in the `main` | ||
branch; and secondly, that the working tree is currently based on `main`, | ||
because that's where `HEAD` points. | ||
|
||
There is a difference between `HEAD` pointing to a branch and `HEAD` pointing | ||
directly to the latest commit of that branch. In the former case (typically the | ||
preferable one), we say that the branch itself is "checked out". When a branch | ||
is checked out, `git commit` will automatically point that branch to the commit | ||
it creates: in other words, it will add the commit to the branch. | ||
|
||
But when no branch is checked out and `HEAD` points directly to a commit (even | ||
if there exists some branch that also points to that commit), `git commit` | ||
doesn't point anything to newly-created commits. This state is called *detached | ||
`HEAD`*, and it's very dangerous: if you ever navigate away from a commit you | ||
make in detached `HEAD`, you may never be able to find it again! Even if you do | ||
write down its hash somewhere, commits that aren't referenced by a branch or tag | ||
can get deleted when a repository is cloned or "garbage collected" (`git gc`). | ||
tchebb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
TODO: Examples of what branches might be used for. Classify into long-lived | ||
branches and development/feature branches. | ||
|
@@ -2167,12 +2217,10 @@ subdirectories (which are sometimes inferred for ease of use). | |
|
||
TODO: `HEAD` as a special ref pointing to your current checkout. | ||
|
||
TODO: Talk about how either hashes or ref names can be used to refer to a | ||
commit. Hashes are immutable, while refs may change. Say that either method | ||
can be used in nearly every place you see us using one of them. | ||
TODO: Refs define what's "in" a repository, more or less. Mention `git gc`, | ||
dangers of committing while in detached HEAD. | ||
|
||
TODO: There are operators that let you "move around" from a ref. For example, | ||
`^` gets a ref's parent commit. Namedrop `man gitrevisions`. | ||
TODO: Hashes are immutable, while refs may change. | ||
|
||
### Exploring multiple branches | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long version or explain or both