electrichilt.blogg.se

Git change branch without changing files
Git change branch without changing files














What’s going on here, really? Why was git able to follow move of. If you try to git log –follow to verify this, you’ll see this:

git change branch without changing files

We still have a deletion and an addition. But, if you think that staging this will help, you’ll be wrong.

#Git change branch without changing files code#

Now rename Foo.al to Bar.al, and add some code in there, like this:įiles are not staged yet, so this is not shown as a rename. In DevOps, you’ll see this (the screenshot is not from the same repo, but it’s the “Show rename history” option that matters): With VS Code, I use GitLens (you should, too!) and this is how you can tell it you want the –follow option with those git logs it issues: Depending on which tool you are using to inspect file history, there are various ways to include rename history. As I said, we’ll get to the bottom of this. So far, we know that git doesn’t lose the history of renamed files, but by default doesn’t show it. Ok, now we are talking business (except for the fact that I fumbled while preparing this demo and had to “Initial” commits, but that’s me, not git). No wonder here, it’s git log that any git GUI tool will run in the background for you, anyway.īut if you read through git log documentation, you’ll notice that it can actually follow the renames. It’s that git – and for a reason, and we’ll get there – doesn’t just show you all that history.

git change branch without changing files

Whatever happened to that initial commit? Why is it not here? Did we just lose all the previous file history? Good news is: nothing is lost (yet). If you commit this, and then look into file history, you’ll only see this: Stage these changes, and you get the following:Īpparently, after staging, git is suddenly able to see this as a file rename. Stay calm, things are under control (so far). This is probably not what you would have expected. When looking in the Source Control, you see this:Īpparently, git sees this as a deletion of. Now you decide to move this file into the right place, and you also decide to rename it in the process. But on other occasions it will not be the case. After you rename a file, sometimes you’ll notice that git detects it as a rename. al files in the project.Īnd this is where git may surprise you. And if you are an AL developer who has ever transformed a C/AL project into AL, you have probably done this at least once, for all. However, sometimes we need to change the file name, or file path, or both.

git change branch without changing files

Git is amazingly efficient when it comes to tracking these kinds of changes. We add new ones and change their content on daily basis.














Git change branch without changing files