I have a project with 3 branches.
running git branch --all shows 6 branches:
branch-A
branch-B
branch-C
remotes/origin/branch-A
remotes/origin/branch-B
remotes/origin/branch-C
It looks like that the local and remotes are not aligned (have different names). How to fix it ?
Related
"refusing to merge unrelated histories" message is showing in git bash when I try to merge two branch. In my project there are two branch respectively main and development. I have made some changes in development branch and want to merge with main branch but git showing this error message.
I do not tried anything actually I do not know the reason of this type error.
I got following environment and setup:
3 load balanced production servers and
one development server
a working auto deployment to my development server with
one gitlab-runner which connects by ssh to my dev-server and pulls the dev-branch and
a gitlab-ci.yml which is limited to my dev-branch
How can I achieve:
further auto-deploy to my development server if I push into my dev-branch
auto deploy to my 3 production servers if I push into my master-branch
The question is based on my current setup where following questions came up
can I let a gitlab-runner run just locally (also not in a docker container because I havn't installed one) so that its just up to the gitlab-ci.yml to differ on branches and deploy to the specific servers or
can I install multiple gitlab-runners which are taking aktion on just specific branches?
or is there another solution which lets me achieve my plans?
"Can I let a gitlab-runner run just locally (also not in a docker container because I havn't installed one) so that its just up to the
gitlab-ci.yml to differ on branches and deploy to the specific
servers"
Yes, register local runners as specific runners with Shell executors on the machines you want to deploy to so they can run local commands just like you use SSH now and only your specific projects can use them. Then take a look at the next sub-answer regarding tags.
"Can I install multiple gitlab-runners which are taking aktion on just specific branches?"
Use either tags to pin certain jobs to runners (e.g. your deploy job) or use only or except to pin jobs to branches or
tags. (e.g. your deploy_prod job only run on master branch)
Example .gitlab-ci.yml file (abstract):
deploy-dev:
tags:
- dev-runner
only:
- dev-branch
script:
- cd mydir
- git pull
deploy-prod:
tags:
- prod-runner
only:
- master
script:
- cd mydir
- git pull
I executed 31 grafts to a local branch and want to strip out 2 of the grafts. The problem is that the 2 grafts are somewhere in the middle, number 5 and 23 out of 31.
What do I execute to strip out these grafts? Also, is it possible to just strip out those 2 grafts specifically and not strip out subsequent grafts?
Thanks
You can do this with the evolve extension. Here are the evolve docs. It is a sharp knife, but a really user-friendly one. Main advice: don't use it on changesets that you already pushed. Let's repeat that:
Assumption: you have not yet pushed any of the changesets you are about to remove, nor any of their descendants.
Check that assumption. Do (if 4 is the number of the earliest changeset you want to prune):
hg log -r 'descendants(4)' --template '{rev}: {phase}\n{desc|firstline}\n'
This prints each changset, followed by its phase, and the first line of its commit message.
None of the phases should be public; all of them should be draft. (Or secret, but if you know about the secret phase then you clearly understand phases.)
Another assumption:
hg log --version
# Should be at least 3.4
Installing hg-evolve
Instructions taken from the wiki. First, clone the evolve repository, and checkout the tag corresponding to whichever version of mercurial you are running. There are tags for 3.4, 3.5, 3.6, 3.7, and 3.8. Ubuntu Xenial ships with Mercurial 3.7.
cd <dir>
hg clone https://www.mercurial-scm.org/repo/evolve/ --updaterev mercurial-3.7
Then edit your .hgrc:
[extensions]
evolve = <dir>/src/evolve-main/hgext/evolve.py
Work in a clone, just to feel safe
For your peace of mind, do this in a clone. To make sure the cloned changesets remain in the draft phase, set your current repo to be non-publishing before pulling from it; otherwise the commits that get cloned will be marked as public on both server repo (the one getting talked to) and client (the one running the clone/pull/push command). The Evolve extension will only alter parts of the history tree that consist of draft changesets.
Mark the server repo, i.e. the one you're currently working on, as non-publishing, in its hgrc:
cd my-project
hg config --local
In the repo's hgrc:
[phases]
publish = False
Next, create the clone.
cd ..
hg clone my-project my-project2
cd my-project2
Tell hg to prune the changesets and repair history
hg prune -r 23
This will make all changesets after 23 'unstable', because they are now based on a revision marked obsolete. You can see the new state of the history like so:
hg log --graph
The obsolete commit 23 will be marked with an x.
To fix the instability caused by modifying the history, run
hg evolve
Which will
take the first unstable changeset (24),
create a stable successor of 24 atop 23's successor -- because 23 was pruned, 24 will be moved atop 22. 24's successor will be e.g. 32.
mark 24 obsolete.
If there are merge conflicts because changeset 24 assumed context that was provided by 23, you will be prompted to resolve the conflicts.
Then, run hg evolve again; which will create a successor of the next unstable changeset in the right place (25 was atop 24; 24's successor is 32, so create 33 atop 32).
Run hg evolve again and again until all unstable changesets have been resolved. Once you feel confident that hg evolve does the right thing (it does), you can run hg evolve --all to move them one after another until there are no unstable changes left.
Now, the obsolete changesets will be automatically hidden: there are no non-obsolete changesets that depend on them anymore.
hg log --graph # hides obsolete commits if they are irrelevant
hg log --graph --hidden # also shows all obsolete commits
Once you're done with that, you can remove commit 4 in the same way:
hg prune -r 4
hg evolve --all
If you want to see your history including obsolete changesets
hg log --graph --hidden
Get your changes back to your main repo
In the my-project2 repo, just push your changes back
hg push
This will push the new successors commits back to my-project. It will also push the obsolescence markers of the ones that were pruned or replaced by a successor.
Clean up
delete the my-project2 repo (unless you want to keep it around)
configure my-project as publish = True again (unless nobody but you pulls/clones from it)
Decide whether to keep hg-evolve in your extensions. Core Mercurial understands obsolescence markers, so you're safe, there -- you can even use hg log --hidden. On the other hand, if evolve is not active and there are obsolescense markers in your repo, you'll sometimes (like when you run hg log) get a warning like obsolete feature not enabled but 5 markers found!
When I sync from the ToolTwist Designer, I select the files I wish to publish, but I get an error when I press OK, saying that the sync failed and to look in the server log file.
If I try again, the files I selected are no longer in the list, but if I check Git I can see they are not pushed to the repository.
In the log file I see that the push failed, and if I go to the webdesign directory and test the push command I get the same error:
$ git push --dry-run
To git#github.com:MyRepository/design-project.git
! [rejected] master -> master (non-fast-forward)
I'm using the 'design' branch, so I'm not sure why an error is occurring on the 'master' branch.
In normal circumstances the Designer only uses a single git branch, normally named 'design'. The error message above indicates a conflict on the master branch.
It appears that changes have been committed to the master branch on the local machine but not pushed, whilst elsewhere changes have been committed to the master branch and have been pushed onto the remote repo.
To clear this conflict you'll need to checkout the master branch and do a pull to merge in the changes on the remote, and then the next push will work. Don't forget to change back to the design branch when you're finished.
[stop the Designer]
$ git checkout master
$ git pull
[resolve any conflicts]
$ git push origin master
$ git checkout design
[start the Designer]
By default git tries to push commits on all branches. In this case, you might find that the conflict on the master branch is preventing your web design changes on the design branch from being committed. To prevent this from happening, you can configure git's default behaviour to only push the current branch.
$ git config push.default current
You might also want to investigate why the master branch is being changed (and in two locations).
In my project , i have local branch for working and branch on network drive
i did "bind branch" between local one and network one
My idea is to use the bind option for auto backup of each local commit.
After i commit files in the local branch , i receive a message in network branch
" Working tree is out of date, please run 'bzr update'."
my question is :
Log on network branch will show the updated tree . Does the files are updated ? or i must do "update" ?
automirror plugin will help me for this scenario?
thanks
Binding a local branch to a remote branch means that commits to the local branch will automatically push that commit to the remote branch. If the remote branch and the local branch are not in sync, the commit will fail and neither the local or remote branch will be affected and your changes will still be sitting in your working tree. To get your local branch in sync with the remote branch, use bzr update.
If your network branch has a working tree, then the working tree is not automatically updated when commits are pushed from the local branch into the network branch. The network branch's working tree has to be updated with bzr update or plugins like automirror or push-and-update.
Unless you actually need the working tree in the network branch, I would recommend that you reconfigure the branch to be tree-less using bzr reconfigure --branch. If you have a shared repository that the network branch belongs to, you will also need to use bzr reconfigure --with-no-trees on the repository to stop it creating trees on new branches.
The 'bind branch' feature will succeed only if your local and network branches are up-to-date.
So the commit failed as there is a difference between these 2 working copies.