![]() ![]() Some people who are used to using different versioning systems, especially centralized ones, could say the branches have the same "content." This isn't entirely accurate when talking about Git, though. So now we have a new branch called "exp", for experimentation. What if something goes wrong and you somehow spoil the beautiful, pristine content of your file? (Yeah, I know it's just some stupid file with "Hello World!" in it, but use the wonderful powers of your imagination and think of the file as a proxy for a much more complex project.) The solution to this dilemma is, of course, creating a new branch: git branch exp That might not sound like the most exciting thing in the world (because it really isn't), but it's certainly less boring than having a repo with no commits at all, right? Now, let's say that for whatever reason you need to change the file's content. We now have a repository with one branch, which has exactly one commit. Untracked files are also uncool, though, so let's track it: git add file.mdĪnd finally, let's create our first commit: git commit -m "First commit" Nothing added to commit but untracked files present (use "git add" to track) If you run "git status", you should see a message saying your file is untracked: $ git status So what about creating a new markdown file with "Hello World!" written in it? echo Hello World! > file.md Now you have a new, empty Git repository. ![]() That's exactly how you'd do it: mkdir my-app Let's say you want to create a new folder called "my-app", enter it, and start a new Git repository. We'll begin with the first way of creating a branch. Besides creating branches, it can also be used to list and delete them, and you can further customize the command by employing a broad list of parameters. Like many other Git commands, "branch" is very powerful and flexible. You create branches in Git, unsurprisingly, by using the branch command. Then we'll end with a little reflection on Git's branching model and branching in general. There are several ways you can create a branch in Git. And without a doubt, one of Git's best features is how it takes away the pain of branching and merging. The tool created by Linus Torvalds has become synonymous with version control. If you write software for a living in 2018, then I can say with confidence you're familiar with Git. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |