![]() ![]() This rather magic-looking command tells your Git to call itself up. refs/remotes/origin/master:refs/heads/master I also assume you have not configured your Git to be a single-branch clone. If you have more than one remote, use git fetch origin -p to make sure you're fetching specifically from the one named origin. The -p is short for -prune, so it deletes any origin/* names that no longer have a corresponding branch in the Git over at the URL stored under the name origin.ġI assume here that you have only one remote, which is named origin. This updates all your origin/* names, 1 including origin/master, without affecting any files in your working tree. If you only delete your X when it explicitly has origin/X set as its upstream, this particular case won't occur-but if someone accidentally deletes your origin/X thinking it was their origin/X, the same problem crops up again, and this time that particular protection does not work.Īnyway, with all that aside, let's look at the variant I suggested above. If you now have your script delete your X, because origin/X went away, that would probably be bad. Then they delete their X (because they're done with it) and delete origin/X. Then someone creates their own X-using the same name-and sends it to the machine from which you git fetch. This X is not related to anyone else's X. Note that this is somewhat dangerous: suppose you have your own branch X on which you are doing development. If I understand what you mean, this requires a script. If you are doing something different, you should include that in your question. I'll assume for now that this is git fetch -prune. I assume this is git pull origin master -ff-only or perhaps just git pull -ff-only. That aside, let's take a look at this particular series of commands, and be very concrete about which Git command you're using: Maybe this is OK and self-correcting when Git un-pauses and finishes the checkout-but it might be better if you could make sure the update only happens when the checkout is done. While it is paused, the watcher tries to combine the multiple files that are now out of sync. Let's say that for some reason, it changes one of several files that the watcher watches, but then it pauses for a few minutes (or seconds, or microseconds, or some unit of time anyway). While git checkout master runs, it's changing various files. There's also a client-side tool that watches the code directory and updates some files. BAT files, or whatever) and aliases (as suggested by Joe in a comment). There are several approaches, including actual, literal batch files (shell scripts on Unix-like systems, or. (Note that I split this into three lines for posting purposes, but as a Git alias using !, it's really all one big line.) Long ![]() Will take care of the first three bullet points-not in the same order-with a single work-tree-updating git checkout step. refs/remotes/origin/master:refs/heads/master & If you are, the second step won't work (see the long section for what will). See the long section for many caveats: the biggest one is that it assumes you're not already on master when you do it. Unless you write your own script (or use a Git alias to run multiple commands and/or scripts), you can't get this down to a single command, but you can get closer. I'm not switching to a new branch from a remote, but to a branch that already exists and it just behind the remote. This question is different from the suggested one in that the local master branch already exists. How can I do that with a git command? I want to bundle up all these actions in a batch file to avoid repeating all those manual steps in TortoiseGit every time. I'm looking for a way to switch to the already-updated master branch in one step. If there's a difference between the issue branch and the old master, there's a good chance that the difference will disappear when updating master (as that issue branch is now merged). When it sees a change in the first step (switch to master), I first need to wait for it to finish before going on (to avoid confusion). There's also a client-side tool that watches the code directory and updates some files (CSS, JavaScript). Also remove their local tracking branches.When it has been merged by GitLab, I need to switch to the current master to do a build, locally. I'm working on a project that's hosted on GitLab and uses issue/work branches and merge requests to bring that work into the master branch when it's done. ![]()
0 Comments
Leave a Reply. |