Git Extensions: How to un "sync" with a submodule - git-submodules

In Git Extensions, I accidentially right clicked and "sync"ed with a submodule, now any current branch I am on is "sync"ed-- so Submodulefoo [mycurrentbranch] in the left hand branch tree ..it was very easy to sync, not so clear how to unsync. Thanks in advance.
whatever branch I checkout is syncing with submodule
synced to new branch

Related

Forbid git svn local branch from committing to the remote svn repository

I'm using git-svn to handle and commit to a svn repository.
I also have created a local branch with commits that I don't want to be committed to the repository.
For safety, I want that branch to be able to do "git svn rebase" but "git svn dcommit" should fail (it doesn't have to be a pretty solution, I just want to make sure that the commits in that branch do not get committed by mistake).
Is there a way to setup the local branch like this ?

Best way to clone a github repository

Ok so here's the scenario.
I made a pretty bad newbie mistake. I was working on some code and didn't create a dev branch to checkout and test in development. So I've made all of these changes to the master branch on my machine that are still broken (in development) and my boss wants me to make some changes to the app in production.
My thoughts on how to do this was:
Rename my project's directory so I have a backup of it
git clone the last remote version back onto my machine
Make the slight changes he wants and re-deploy/commit
Sort out what I've changed in my old version of the app and bring it into a dev branch into the newly cloned master branch.
Any thoughts on this? I really don't want to screw up production right now and I've made too many changes to keep track of to revert to where the code was stable.
No need to go through that much trouble:
git checkout master # get the 'bad' version
git branch bad-master # make a new branch called 'bad-master', cut off master's current state
git fetch # make sure you're up to date with the remote
git reset --hard origin/master # reset your master branch to origin/master's state
<work work work>
git checkout bad-master # when you're ready to work on bad-master again
Note that git reset --hard origin/master will discard any work in your working tree that you haven't checked in... so if you've got work you haven't committed yet, be sure to git stash it.
This is a completely normal situation to wind up in, and one you can easily recover from.
All you need to do is:
Create a new branch pointing to your current version of master
git checkout -b my-feature-branch
Reset your master to the same thing as origin/master
git checkout master
git reset --hard origin/master
That's it. Now your master is the same as it was before you did your feature development, and you have a feature branch set aside which you can later checkout to resume development.

git submodule update needed only initially?

I'm getting a hang of git submodule (wishful thinking?) and I'm coming up with more specific questions, which is a good sign...
I've tried to find the which revision of the submodule the superproject refers to, in .gitmodules and .git/config, but nothing is mentioned there...
The scenario is that I'm changing submodules in their root locations (from which they're imported), and then pulling them in where they're "submoduled"...
Beyond committing from the superproject to incorporate those changes into the superproject repo, do I also need to do "git update" to register the new pulled in submodule commits?
Basically the question is:
do I need to "git submodule update" only when I first clone the superproject, or after every pulling of the submodule (from its own repo)?
Thank you
As mentioned in my previous answer to git submodule update, that command checks out the specific version of the project, base on their .gitmodules file.
The GitPro page does insist:
This is an important point with submodules: you record them as the exact commit they’re at.
You can see which commit is referenced by running within the "super project" (the one referencing one or several submodules):
git submodule status (except if you did some commit directly within that submodule, in that case it will show a "+" in front of the SHA-1 of the HEAD of any submodule that has advanced from the SHA-1 stored in the superproject) or
git ls-files --stage looking for entry in mode "160000", a special entry in the Git index.
That means, each time you execute a git command in the "super project" which could modify that submodule commit SHA1, you need a "git submodule update".
do I need to "git submodule update" only when I first clone the superproject, or after every pulling of the submodule (from its own repo)?
Yes, you have to do this every time you pull down a submodule change in the main project.
That is because you are referencing the exact commit the submodule original repo is at (as said above), and when you pull that repo, you are effectively modifying that commit.

Bazaar offline + branches

I have a Bazaar repository on Host A with multiple branches. This is my main repository.
Until now, I have been doing checkouts on my other machines and committing directly to the main repository. However, now I am consolidating all my work to my laptop and multiple VMs. I need to be working offline regularly. In particular, I need to create/delete/merge branches all while offline.
I was thinking of continuing to have the master on Host A with a clone of the repository on the laptop with each vms doing checkouts of the clone.
Then, when I go offline, I could do bzr unbind on the clone and bzr bind when I am back online.
This failed as soon as I tried to bzr clone since bzr clone only clones a branch(!!!!)
I need some serious help. If Hg would handle this better please let me know (I need Windows support.) However, at this moment I cannot switch from Bazaar as it is too close to some important deadlines.
Thanks in advance!
bzr fundamentally works with one branch / directory (the branch are visible at the file system level), so if you need to clone each branch from your repository (not unlike svn, in a way). Hg, at basic level, works this way too (although you can put several branches in one repository using say named branches).
For DVCS, it is important to distinguish between the following:
Working tree: a versioned set of files (at a given revision)
Branch: a linear set of revisions
Repository: a set of revisions
When you clone locally a directory versioned by bzr, you are copying the repository subset which contains all the revisions in the branch you are cloning, and get the working tree. This assumes you are not asking for a branch wo a working tree nor using a shared repository.
What you want, IIUC, is to clone the full repository with all the branches. There is no 'native' way to do so in bzr I believe, but plugins to help you toward this, like multi-pull and push-repo, to sync multiple branches in one shot.
But I don't understand why that's such a big problem, or the link with working offline: you just clone the branches you want to work on your laptop.

How to dcommit only selected patches with git svn?

I have a number of locally committed patches in my git-svn repo which I haven't yet commited to our svn repo. A normal "git svn dcommit" will commit all of these patches to svn. I would like to commit only some of my patches (simple bug fixes), but not others (untested major changes). How can I do this with git svn?
I've been following the procedure here:
http://fredericiana.com/2009/12/31/partial-svn-dcommit-with-git/
If you're comfortable rebasing, it works pretty well.
Here's what I ended up doing. The starting point is the "master" branch synced with svn, with all of my local patches on top.
Create a new branch (wip = Work In Progress).
git branch wip
This makes a copy of the current branch, including all patches not yet committed to svn. The current branch will stay as "master" and will not be changed.
Remove the unwanted local patches from "master" with a rebase:
git rebase -i HEAD~10
Now the "master" branch has patches you can safely commit:
git svn dcommit
The "wip" branch now has the major changes which aren't yet ready for sharing. Actually, I want them to stay there and this is where I would stop. It's possible to do the svn dcommit from the "wip" branch once everything is finalized. But for completess' sake, and to answer the original question, there's a final step:
Pull the uncommitted changes back to the "master" branch using git cherry-pick and finally remove the useless branch with git branch -d wip.
With git, you're not actually supposed to operate on single changesets. The best approach I know is to create local branches for any non-trivial work. This way, your untested major changes will end up in different branches of your git repository, and you'll be able to differ them quite easily.
If this is the problem you have at the moment you can probably create create a new branch from the point you last updated from svn and then use git-cherry-pick to transfer your simple bug fixes to this new branch, from which you can then dcommit to svn.
From a more long-term point of view it's best to have your own "master" branch made from subversion trunk, and then either:
Rebase all your branches every time you update from svn, then merge those you want to get to svn to your master and dcommit from there.
Merge stuff from svn using regular git-merge, and then merge stuff to your master for dcommits by git diff ..my_branch | patch -p1, which will eliminate history that git-svn can't handle. This approach is more complicated for the final merging but allows you to merge stuff between branches (and possibly other people) in git itself.