Exercises

Classroom-tested by tens of thousands of students, this new edition of the bestselling intro to programming book is for anyone who wants to understand computer science. Learn about design, algorithms, testing, and debugging. Discover the fundamentals of programming with Python 3.6--a language that's used in millions of devices.

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




4.4 Managing Files

Pragmatic Version Control — Pragmatic Programmers (37 / 103)

👈 4.3 Seeing What Has Changed | TOC | Chapter 5 Understanding and Using Branches 👉

Now your repository is starting to come together. With one file, it’s pretty simple right now, but as it grows, some cleanup is necessary.

Files need moving, code needs to be copied around, and some of the everyday cruft from working with your project needs to be ignored.

We all write flawless, bug-free code on our first pass. Right? Even though we would like to think that we do, we sometimes get things wrong. Naming a file incorrectly or putting it in the wrong directory is no exception.

You can move a file in Git by typing git mv <original-file> <new-file>. The command tells Git to create new-file with the existing file’s content, and it keeps the history and removes original-filename.

Your “Hello World” page is not an index, so let’s move it:

git mv is a convenience. Git can detect the movement of a file, but more steps are involved. You have to move the file and then call git add on the new file and git rm—the command to remove a file from the repository—on the old file.

Go ahead and commit the new hello.html move:

Now that you’ve renamed the index.html file, let’s talk about copying files.

If you’re used to Subversion, you might find it odd that Git doesn’t have a git cp command for copying. There’s a reason—Git doesn’t need it.

Subversion’s copy is mainly to let you create branches and tags — Git provides you with the commands to handle both of those directly. Git does track copied code, though.

Add a comment

Related posts:

9 Identity and Access Management Best Practices for 2021

2020 has not been a good year in the history of cybersecurity and identity management. With the pandemic forcing many organizations to shift their workforce to remote environments abruptly, security…

Conventions

When traditional web development techniques don't cut it, try React. Use React to create highly interactive web pages faster and with fewer errors. With a little JavaScript experience under your belt, you'll be up and running in no time creating dynamic web applications. Craft isolated components that make your apps easier to de

Why Authenticity Will Always Be Your Creative Superpower

No matter who you are or what you're selling, authenticity will always be your creative superpower. I recently asked this question on Twitter, "What is the most important skill when creating online?" Some agreed.