Git, snapshots and references
I've been using Git for fun for a while, but nothing more than creating a repo, adding files, committing and pushing to a remote.
That's like a complicated way of using git as an alternative to ftp. If I wanted to revert to a previous version, I'd have no idea how to do it. And since I'm not collaborating with others, I'm basically duck hunting with SAM rockets.
So I tried to create a branch in order to understand how Git is an effective way of keeping my code clean and tidy. I thought my changes was going to be stored in the new branch, but when i checked my master branch back out, it had all the changes I made in my new feature branch.
The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. Conceptually, most other systems store information as a list of file-based changes (..) Git doesn’t think of or store its data this way. Instead, Git thinks of its data more like a set of snapshots of a mini filesystem. Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.
From git-scm.com
So it's like playing a game and saving at certain points, or check points. I guess a branch is a sequence of check points you can go back to. But still, this puzzles me:
You're in a new feature branch, working. And then need to start on a different branch. You have to commit (or loose all changes, I guess), switch to master, reset to latest commit in master, create a new branch and switch to that. Make some changes, and save a commit.
Since Git is a version control system, git status will compare the current state of the files to whatever the state was a the last commit for the branch you are in. But switching between branches wont change the files. They are what they are. All that changes is the difference between status quo and the previous commit in that branch.
If I understand this correctly.
Etiketter: git, Technology, version control

0 Kommentarer:
Legg inn en kommentar
Abonner på Legg inn kommentarer [Atom]
<< Startsiden