![]() Known limitation for both my aliases: the remote has to be called origin. ![]() I often find the unsafe alias useful too, in particular when I do want to discard some work on my local copy of the branch, so I also kept it as ff-force: # Not safe - reset the specified branch to its state on origin, even if it's not a fast-forward merge and potentially throws away some commitsįf-force = !sh -c 'git update-ref refs/heads/$1 origin/$1' - In the latest version of vscode that Im using (1.17.0) you can simply open the branch that you want (from the bottom left menu) then press ctrl+shift+p and type Git: Merge branch and then choose the other branch that you want to merge from (to the current one) Share. Git update-ref refs/heads/$1 origin/$1 `git merge-base origin/$1 $1` " " \ ![]() All you have to do is check out the branch you wish to merge into and then run the git merge command: git checkout master Switched to branch master git merge iss53 Merge made by the recursive strategy. If ] " " then \Įcho $1 is checked out, use pull or merge instead. In order to do that, you’ll merge in your iss53 branch, much like you merged in your hotfix branch earlier. # as it's safe: $1 is not checked out, and a fast-forward merge is possible. Here is the second version of this alias, with a safeguard so that it only does fast-forwarding, and refuses to do anything in other situations: # Do a fast-forward merge on the branch specified as argument, as long However, this is unsafe because it will do the update even if is not equivalent to a fast-forward merge, and therefore it might discard some commits. Once this alias is defined, your operation becomes: git fetch More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the. As stated in the official Linux Kernel git pull documentation: In its default mode, git pull is shorthand for git fetch followed by git merge FETCHHEAD. You call it by typing git ff some_branch, and it uses update-ref to set that branch to origin/some_branch. git fetch origin git merge origin/master Documentation. Here is a simple (but unsafe) version of this alias: ff = !sh -c 'git update-ref refs/heads/$1 origin/$1'. Created new branch branch2 from branch1 Renamed the file b1.txt to b2.txt + also in common.txt I changed that line to echo line added in branch2. ![]() I have created an alias in the section of my ~/.gitconfig to update master (or any branch) to origin/master without checking it out. I have the following scenario: Created new branch branch1 from master In branch1, I added a new file called b1.txt + also in common.txt I added new line echo line added in branch1. I face your scenario constantly and rapidly got tired of doing it more or less like you described, so I created an alias to fast-forward master without switching to it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |