I've got a git repository that was migrated from a TFS repository. There is currently no link between the repositories.
If I use git tfs list-remote-branches {http://...TFSRepo}, I can see the branches in TFS.
What I want to do is be able to pull a TFS changeset into my current git repository -- preferably as a commit, but I'd take just pulling the changes into the current branch.
quick-clone doesn't do what I need as it creates a new git repository (buried in my existing git repository...)
Is is possible to perform a pull of a single TFS changeset using the git-tfs extensions?
There is no way to pull only one changeset in an existing git repository that is not a git-tfs repository.
But you've got 2 possibilities to achieve your goal...
The first is to do a quick-clone in a new repository and then add this repository has a remote and fetch the commit you want.
The second is more tricky, less sure to work because you must understand how git-tfs works.
Amend the last commit to add at the end of the commit message something like that:
git-tfs-id: [https://tfs.codeplex.com:443/tfs/TFS16]$/valtechgittfs/BugMerge;C31467
with :
git-tfs-id: [https://url.tfs.server:/tfs/TeamCollection]$/ProjectName/BranchName;CchangesetId
where you specify as the changeset id, the one of the last changeset before the one you want to fetch. Then, if you have at least the v0.20 of git-tfs, then, fetch changesets...
Related
Long back I have created a pull request to merge my branch into master and it was done. I think the merged branches will not be available on Bitbucket for longer time? (Anyway, my branch is not available).
But, is there a way to recover that branch in Bitbucket?
I know how to recover it on git/sourcetree, but I want in Bitbucket to create another branch from this.
I have used this command to recover my branch to sourcetree,
git checkout -b <branch> <sha>
Created a tag from last commit of my branch and created branch from that tag.
I have two branch in git-tfs. one is master and other is QA, this branch is created from master previously. All the recent changes are in master. Now i want to get the changes from master to my QA branch. how to get that? I want to get done that from the browser.
If you are talking the git-tfs command tool, you could also manager merges with git-tfs.
If you want, for example, to merge the branch b1 in the trunk
trunk, you need that b1 and trunk to be entirely checked in
Tfs. Once done, you could do the merge with git as a normal merge
with 2 local git branches. Then you have to check this commit into
Tfs with the command rcheckin and a merge changeset will be created
into Tfs.
More details please refer this tutorial git-tfs ,but it's not able to do this from the browser.
If you are just talking about the GIT source control in TFS, and want to get done that from the browser. The only way is creating a pull request. Detail step just follow this thread: Create a pull request
You will just have to synchronise the branch with the master and it will do, i.e in easier terms synchronisation of a branch means to merge the master into that branch. That's it!
Using LibGit2Sharp, how can I fetch the list of all Remote Branches given the repo url ?
I do not have a clone of the repo on the local disk. What's the simplest way to get the list of Branches and once I get the list of branches, I'd like to get the list of Commit Id's in a branch of my choice.
I do see a way to do all this if I have a Git Repo cloned on my local disk but, I don't want to clone it for obtaining this info.
Using LibGit2Sharp, how can I fetch the list of all Remote Branches given the repo url ?
I do not have a clone of the repo on the local disk. What's the simplest way to get the list of Branches
Through LibGit2Sharp, one can read information about the references (mostly branches and tags) of a remote repository, without cloning it. This will retrieve the name of those references and the sha of the commit each one points to.
This can be done through the IEnumerable<Reference> ListRemoteReferences(string url) static method. This is the equivalent of the git ls-remote CLI command.
once I get the list of branches, I'd like to get the list of Commit Id's in a branch of my choice.
Unfortunately, ListRemoteReferences() will only return the tip of each branch. Would you need to enumerate the other commits referenced by this branch, only using LibGit2Sharp, you'll have to locally clone the remote repository.
As an alternative, rather than cloning, once you've got the SHAs of the tips, you could leverage the Commit GitHub API and for each commit, retrieve its parent(s), reapplying recursively the API invocation for each of them. Note that this last option will be far less performant (network I/O, API rate limitting, ...).
I'm busy experimenting with git-tfs do tfs to git conversion. I understand the cmd below will clone everything and convert TFS branches into the git repository:
git-tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1/Trunk --with-branches
There are a number of branches I don't want moved over - is there a way I can exclude one or more specific branches?
thanks
You won't be able to exclude any branches during the clone operation. It's an all or nothing operation.
Remember that branches in git (pointers to commits) are different to branches in TFVC (folders) so if you're not planning on pushing back changes to the TFVC repository afterwards then you can simply delete the branches you don't want by using git branch -D operation on each of the branches you wish to exclude.
After the clone don't forget to do a git gc and a git tfs cleanup to minimise the size of your git repository.
In JIRA connected with STASH you can create a feature branch for an issue using the button 'create branch'. (That is nice to track the commits in this issue.)
If a developer started working but did not know that there is such an issue he did not click the 'create branch'.
Is there any possibility to assign an existing git branch to an issue?
ex-Stash developer here.
Yes and no. Creating the branch though the UI is just a convenience. The important thing is that the name contains the JIRA key. If only one developer is working on the branch, it's fairly easy to just rename (delete + add) a branch with the appropriate name.
git checkout old-branch
git push -u origin old-branch:JIRAKEY-1234-something
git push origin :old-branch
Does that help?
Update
As for january 2017 if you have an already exiting branch and you want to attach it to a Jira Issue you can do the following:
Checkout to the branch you want to rename
Execute the following command
git branch -m JIRA_ISSUE_ID-Whatever
Assuming that mine Jira issue is SO-01 I can do the following:
git branch -m SO-01-Whatever
This will change the name locally, push it to remote with:
git push origin :old_name
Command Syntax
git branch (-m | -M) [<oldbranch>] <newbranch>
Related question for more info
This is no longer the case. With a common setup between bitbucket and Jira, simply including the issue ID in the commit message will create a link between the commit, and thus the branch, and the issue in Jira.
I just tested the theory that having the Jira ID in the branch name creates an automatic link.
It does.
To see the effect, you have to push a commit. Then the branch will show up in the Jira.
The branch shows up in Jira, but to get an individual commit to show up in Jira I have to refer to the Jira ID in the commit message.
The web interface option is to branch off a branch but merge back to master in the pull request.
eg:
click create branch in jira
set the repo, branch type and name to what you want
set the branch from to be the existing branch
click create
when creating a pull request set the destination branch to what you want eg master
If you include the JIRA-ID in the branch name, by creating out of an existing commit, all you have to do is:
git push --set-upstream origin <new-branch-name>
and the branch is attached to the JIRA ticket.
Just add a new commit with the Jira issue key in the commit message