Integrating Github code to TFS - auto check-in - github

We are using one of the project from Github. We need to check-in code of this project in our TFS.
We need to automate this process. Else everyday we need to download the code and then check-in.
Is there some plugin or some tool to automate this?

If you are using a TFVC repository in TFS then you'll probably want to build some scripts and a process around Git-TF to help automate some of this work.
If you are using a Git repository in TFS then you can create set up two remotes in a local Git repository, i.e
git remote add upstream https://github.com/foo/bar.git
git remote add origin https://tfsserver/DefaultCollection/_git/bar
And then simply do a git pull upstream master followed by a git push origin master assuming that master is the branch that you want to keep in sync.
With either version control system, you probably want to keep a branch in version control in your TFS repository to match what is in your upstream GitHub project so that you can easily see change coming in the one place and then handle your merges inside your local repository.

Related

Whats the easiest and noob friendly way to move changes from github to tfs?

I have a project hosted on TFS, let's call it GenderBlender. Two teams work on GenderBlender. One team got the latest code from TFS and hosted it on Github. Made some commits to that GitHub. How can I move those changes from Github to Tfs without commit history and just one big commit under my account?
I will be moving it from my local git repository to my local tfs repository and then committing them to the tfs.
That is actually the idea: copy the all files from the Git repo to the tfs working tree (be it a TFVC workspace or a Git one)
If it is a Git repo, Git will detect the changes: add and commit.
If it is a TFVC workspace, use a reconcile command to detect the changes

On-premises GIT repository with Visual Studio Team Services Project

We have on-premises installed GIT. There we have our code repositories.
Is it possible to connect a repository from this on-premises instance to Visual studio team services project?
So they display under "Code" bar?
vsts
I need it hosted on premises, but see code changes/commits and other GIT stuff in VSTS project
No, it isn’t supported to display files or code of another repository under Code bar. You need to import that repository to the repository in VSTS. After that, you can push updates to VSTS repository if there are changes in your on-premises git repository.
You can't connect on premise GIT to VSTS. You may however use the VSTS rest APIs to push in code from your on premise GIT to VSTS.
Typically you will setup a hook/trigger on your on premise GIT repo in order to automate the replication process.
As others have said, you can have a "git hook", which is basically a git trigger to take action on some event. In this case, when code is pushed, to push it up to VSTS, but I assume you need to know the technical commands.
I had to do this the opposite way, and I did this quick and dirty. This pushes everything in one go, not each commit. This can also catch up a repo that is behind.
# Clone source repo (your local git repo)
git clone some_repo_path_goes_here
# I am skipping steps and assuming you are only syncing master branch.
# I have code to get all branches down before proceeding, but not posting it here.
# Assuming tags are on master branch..
# Get all tags
git fetch origin --tags
# Test to see if remote alias already exists
git ls-remote http://path_to_.visualstudio.com/org/project/_git/TargetRepoSameName
# Add a remote alias
git remote add any_name_123 http://path_to_.visualstudio.com/org/project/_git/TargetRepoSameName
# push local repo to 'any_name_123'
git push any_name_123 --all
# optional: delete all tags before attempting to push local tags
git push any_name_123 --delete `$(git tag -l)
# push local tags to remote repo
git push any_name_123 --tags
You can schedule this job if you would like. I have a PowerShell job to do this with a lot more functions to do pull down the branches.

Git : How to coordinate work on multiple repositories

Scenario: I'm mostly working with Eclipse to develop plugins. We have our repo that represents our development activities. Now I sometimes need to make some changes to a number of Eclipse or other 3rd party plugins, which are themselves hosted on Git. Then I need to have those modified plugin projects available as part of my codebase.
What I would like to do is to integrate all the remote repositories into a coherent local version where I can pull updates from those other read-only repos, but the changes that we make can be seen in our own repo, just like any other local working directory.
It sounds like you want to use the git subtree command http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/
"The command to update the sub-project at a later date becomes:"
git fetch tpope-vim-surround master
git subtree pull --prefix .vim/bundle/tpope-vim-surround tpope-vim-surround master --squash
"When it’s time to contribute back to the upstream project we need to fork the project and add it as another remote:"
git subtree push --prefix=.vim/bundle/tpope-vim-surround/ durdn-vim-surround master

How to convert a remote branch into a local one in Eclipse using Bitbucket?

I'm kind a newbie on Bitbucket so I have a lot of doubts.
I share an Eclipse project between two different computers. I have pushed the project from one computer to the Bitbucket repository using the Eclipse plug-in. Now when I go to the other computer I have fetched the repository that is saved on Bitbucket, and it has created a new remote tracking branch on my Eclipse local repository.
My problem comes when I want to merge that branch with the local branch, I have no idea how can I do that
Anyone could help me?
ps: sorry if the problem or the situation is not very clear
You should follow the section "Pulling New Changes from Upstream Branch ":
a git pull is a fetch + a merge.
Right-click on a project in the Package Explorer and select Team > Pull or right-click on a repository in the Git Repositories view and select Pull to pull new changes from the upstream branch your local branch is tracking.
The section "Fetch and Pull" of the Egit tutorial says as much:
When cloning remote repositories, Git creates copies of the branches as local branches and as remote branches.
A Fetch operation will update the remote branches only.
To update your local branches as well, you will have to perform a Merge operation after fetching.

EGit Local vs. Remote repositories

I'm new to git and am wrapping my head around how I'm supposed to be using git and egit. From the egit tutorial, I have setup a respository on GitHub, pushed my Eclipse projects to the remote GitHub repository from my local workspace, I can push changes to GitHub, switch branches, see the updates on GitHub, etc. This all makes sense.
Looking at the Git Repository explorer, I have a listing of "Local" branches and have no "Remote Tracking" branches and I have no "Remotes" listed. When I create a branch from a local branch, the egit dialog indicates "You are creating a branch based on a local branch" and suggests that I should be making a branch from a remote tracking branch.
So my question is, am I correctly using egit?
Should I just continue pushing changes to the remote GitHub repository? If so, what happens once I share the project and other developers clone the repository and start making changes to the remote repository?
Or should I now ditch the local repository and setup a new remote repository by cloning the existing GitHub repository that I initially created from my workspace?
Or do I create a new Push and Fetch "Remote" for my existing git repository?
Or something else?
Confused.
Since you created the repo on your local system and then pushed it to github without creating a remote you don't have a remote at hand. A remote is simply a short alias for the remote repository's URL. To fix this create a remote and a push and fetch configuration from the repositories view. In order to populate remote tracking branches in your local repo you need to run fetch once. As soon as this is done you can use "Push to upstream" instead of the more complex Team > Push... dialog which allows to define all parameters on the fly. When using native git command line you'll find the same concepts implemented there:
with
"$ git push [url] [refspec]" (e.g. "$ git push https://github/user/myrepo.git master:master")
you pass all parameters explicitly, this is similar to Team > Push... in EGit
with
"$ git push [remote]" (e.g. "$ git push origin")
you push to the repository defined by the configuration parameters of the given remote (check .git/config to see these parameters or open repository configuration from egit preference in Eclipse), this is similar to Team > Push to upstream in EGit. Usually the refspec used in this way is implicitly configured when creating a local branch based on a remote tracking branch. It's also possible to add this configuration later but since this is more
tedious manual configuration the other way is more handy.
If you clone a remote repository the repository you cloned from is stored as remote "origin" in your clone. This way you can skip configuring the remote manually. This is only needed if the repository is born when you create it from scratch.
The "Branching" section of the Egit User Guide can help:
There is no obligation to create a local branch which would be named like a remote tracking branch (see "Having a hard time understanding git-fetch" to have a good understanding of "remote tracing branches).
You can create as many local branches (i.e. branches that you won't necessary push anywhere) as you want/need.
But if you don"t see any remote branch, maybe you didn't fetch that GitHub repo in the first place: see Fetching.