Rebase modifies the history of our branch. # from the feature branch git rebase origin/master But we can simulate this scenario with a simple command. This would be a terrible workflow, preventing us from working in parallel with our colleagues. Ideally, we would have waited for the commits B and C from our diagram before making our own branch. We get a new weird, auto-generated commit, and our tree becomes two-dimensional, making it hard to read. This adds quite a lot of complexity to our history. Instead, it will have to create a merge commit to reconcile the history of the two branches. This means Git won’t be able to perform a fast-forward merge. But by the time our feature is ready, new commits have probably been added to the master branch. When we’re coding a new feature, it’s a good practice to work on a separate branch – often called a feature branch. Both GitHub and GitLab let you combine your commits when you decide to merge your branch. The most convenient way to squash commits is during Pull Requests. # Squashes the last 3 commits git reset -soft HEAD~3 & git commit You can squash the commits using the CLI, but the syntax is quite fuzzy ( from Stack Overflow): Suddenly your history becomes neat and relevant. That means combining them into a single commit that contains all of their changes. To clean up a bunch of redundant commits, you can squash them. And that’s fine – as long as they don’t stay around forever. They’re just here to let me go back in time if I mess up too much. It’s hard giving each one a meaningful name, because they have no individual value. But they end up spread out across commits like this: Some changes only make sense when grouped together. They reflect what my days look like, not what’s in my code. But that means my commits become meaningless. It makes me feel safe knowing my changes are saved somewhere, so I commit every time I take a small break. Here’s how to avoid flooding it with useless noise. Your project’s Git history is a powerful time machine. All articles 5 Tips to Keep a Clean Git History
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |