Wednesday, August 14, 2019

Share your code in Git using Eclipse

Share your code in Git using Eclipse


Share your Eclipse project with your team in an Azure DevOps Services/TFS Git repo.

Prerequisites

  • An Azure DevOps organization. If you don't have one, you can sign up for one for free. Each organization includes free, unlimited private Git repositories.
  • A local Eclipse project. If your code is already in version control in Azure Repos or TFS and you want to clone it, see Clone an Azure DevOps Services Git repo using Eclipse.

Use Team Explorer Everywhere

Team Explorer Everywhere is an open-source Eclipse plug-in to connect Eclipse to Azure DevOps Services or Team Foundation Server. If you're working with Azure DevOps Services/TFS and Eclipse, use this plugin to connect to your repos, builds, and work items.
 Note
The Team Explorer Everywhere plug-in works with Eclipse versions 4.2 (Juno) - 4.6 (Neon).
  1. Add the Team Explorer Everywhere view in Eclipse. Go to Window, Show View and select Other... Search for Team Explorer, select the Team Explorer view, and select OK.
    Add the Team Explorer view to Eclipse

Connect to Azure DevOps Services

  1. In the Team Explorer Everywhere view, select Connect to VSTS or a Team Foundation Server .
    Select Connect to Team Foundation Server to connect your TFS or Azure DevOps organization
  2. If you know your Azure DevOps Services or Team Foundation Server account URL, select the Servers... button under Connect to a Team Foundation Server or Azure DevOps organization to add your TFS server or account to the drop-down list. If you don't know your account information for Azure DevOps Services, select Browse Visual Studio Services and select Next.
    Add Existing Project Dialog
    Either choice will prompt for your credentials before continuing further.
  3. Select the project where you will share your code from the Project Selection dialog and select Finish.

Create a local Git repo for your Eclipse project

Before you can push your project to Azure Repos, you need to add it to a local Git repo.
 Note
If your code is already in a local Git repo, you can skip this step.
  1. With your project open in Eclipse, right-click the project name in Project Explorer and select Team, Share Project... Select Gitand select Next.
  2. Select Create... from the Configure Git Repository window and choose a folder for your local Git repo. Select Finish.
    Create a local Git repo in Eclipse
  3. Right-click your project in Project Explorer and select Team, Commit.... Stage your changes by dragging your files to the Staged Changes field, enter a commit message, then select Commit.
    Commit your code with Git in Eclipse

Push your project to your Azure DevOps Services/TFS repo

  1. In Team Explorer Everywhere, select Git Repositories, then right-click the empty repo you want to push your Eclipse project to and select Copy Clone URL. If you don't have an empty Git repo created in Azure DevOps Services/TFS yet, you can create one using these instructions.
    Copy the Git repo clone URL in Team Explorer Everywhere with a right-click
  2. In Package Explorer, right-click your project and Select Team, Push Branch ... . Paste the clone URL from the clipboard into the URI field and select Next. Make sure Configure upstream for push and pull is selected in the next window and select Next.
    Push your code to Azure Repos using the Clone URL from the web
  3. Review the changes and select Finish in the Push Branch window.
Your project code is now in your Git repo.

Visual Studio Team Explorer Everywhere for Eclipse (Azure DevOps Services and TFS)

Visual Studio Team Explorer Everywhere for Eclipse (Azure DevOps Services and TFS)

 Note
The Team Explorer Everywhere plugin works with Eclipse versions 4.2 (Juno) - 4.6 (Neon).
Visual Studio Team Explorer Everywhere (TEE) is a plug-in for Eclipse that enables you to work with Team Foundation Server (TFS) and Azure DevOps using both Team Foundation Version Control (TFVC) and Git version control systems.
For information on connecting to an Azure DevOps Services Git repo from Eclipse with TEE, read Share your code with Eclipse and Azure DevOps Services Git.

Eclipse Update Site for Latest Release

The latest release of TEE can always be installed in Eclipse using this update site URL:

To install Team Explorer Everywhere from within Eclipse

  1. Click on the Eclipse icon in the toolbar to open the Eclipse Java IDE.
    Click Eclipse in the Toolbar
  2. The first time you run Eclipse, it will prompt for default workspace. Click on the box "Use this as the default and do not ask again" to use the default workspace on startup.
    Accept the default Eclipse workspace
  3. When the Welcome dialog appears, on the Help Menu select Install New Software.
    Click on Help > Install New Software
  4. Choose the Add button to add a new repository. Use Team Explorer Everywhere as the name. The location of the update site is https://dl.microsoft.com/eclipse.
    Add Repository
  5. Choose the OK button.
  6. In the list of features in the Install dialog box, select the check box that corresponds to the Team Explorer Everywhere plugin. If you don't see this option, use the pull-down menu for "Work with:" and find the update site URL you just entered in the list and select it, then select the check box beside the plug-in mentioned above.
    Select Team Explorer Everywhere
  7. Choose Next two times. Accept the license agreement and choose Finish
  8. Eclipse will need to restart.

Tuesday, August 13, 2019

Adding an existing project to GitHub using the command line


Putting your existing work on GitHub can let you share and collaborate in lots of great ways.
If you are migrating your project from CodePlex, read the migration guide for more information.Hub Desktop Help.


Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.
  1. Create New Repository drop-down
  2. Open Git Bash.
  3. Change the current working directory to your local project.
  4. Initialize the local directory as a Git repository.
    $ git init
  5. Add the files in your new local repository. This stages them for the first commit.
    $ git add .
    # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
  6. Commit the files that you've staged in your local repository.
    $ git commit -m "First commit"
    # Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
  7. At the top of your GitHub repository's Quick Setup page, click  to copy the remote repository URL.
    Copy remote repository URL field
  8. In the Command prompt, add the URL for the remote repository where your local repository will be pushed.
    $ git remote add origin remote repository URL
    # Sets the new remote
    $ git remote -v
    # Verifies the new remote URL
  9. Push the changes in your local repository to GitHub.
    $ git push origin master
    # Pushes the changes in your local repository up to the remote repository you specified as th
To checkout a specific feature branch

git clone -b <branch> <remote_repo>
When you do a pull request on a branch, you can continue to work on another branch and make another pull request on this other branch.
Before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
$ git pull origin {name of the remote branch}
Create the branch on your local machine and switch in this branch :
$ git checkout -b [name_of_your_new_branch]
Push the branch on github :
$ git push origin [name_of_your_new_branch]
When you want to commit something in your branch, be sure to be in your branch. Add -u parameter to set-upstream.
You can see all the branches created by using :
$ git branch -a
Which will show :
* approval_messages
  master
  master_clean
Add a new remote for your branch :
$ git remote add [name_of_your_remote] [name_of_your_new_branch]
Push changes from your commit into your branch :
$ git push [name_of_your_new_remote] [url]
Update your branch when the original branch from official repository has been updated :
$ git fetch [name_of_your_remote]
Then you need to apply to merge changes if your branch is derivated from develop you need to do :
$ git merge [name_of_your_remote]/develop
Delete a branch on your local filesystem :
$ git branch -d [name_of_your_new_branch]
To force the deletion of local branch on your filesystem :
$ git branch -D [name_of_your_new_branch]
Delete the branch on github :
$ git push origin :[name_of_your_new_branch]

If you want to change default branch, it's so easy with GitHub, in your fork go into Admin and in the drop-down list default branch choose what you want.
If you want create a new branch:
$ git branch <name_of_your_new_branch>

OCI Knowledge Series: OCI Infrastructure components

  Oracle Cloud Infrastructure (OCI) provides a comprehensive set of infrastructure services that enable you to build and run a wide range of...