Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Wednesday, June 5, 2013

How to create a new git local branch and push to repository (remote/origin)

From your terminal using commands
Check your git version with the following command,
git --version
if you have git version equal or greater than 1.7.0, you should be able to do with the following commands.
git checkout -b newbranch

git push -u origin newbranch
The first command creates a new branch from your current local branch. In order find what's your current branch use the command "git branch -a". It will list all available branches, the current branch will be preceded with a *.
The "-u" option is available only from git 1.7.0. It refers to "upstream" to where you want to push to or pull from.

From eclipse
Right click on your eclipse project Team -> Switch to -> New branch.

Create branch from eclipse

Give your new branch name in the following dialog and then click Finish. This will create a new branch from your current working branch.

Make all your changes to the new branch, to push the newly created branch right click Team -> Commit & Push (EGit2.x versions).

From github
The simplest way to create a new branch is from Github. If you have push access to the repository, start typing the new branch name in the search box of switch branches/tags. This box will appear once you click on the down arrow near branch. Once you complete typing the branch name, you will see an option to create new branch with the name provided. Click on it, you are done.

Create branch from github

submit to reddit

Thursday, May 16, 2013

Git for beginners

Getting started with Git

I would advise to read through what is Git, and have a decent understanding of SCM process.
The first question everyone would get is why I should move away from my current SCM systems(CVS or SVN).  Well there are lot of articles around this topic if you google,  just a couple of quick reasons I would give to go with Git,
  1. Works the best if you are working decentralized.
  2. Stop questioning and just "Go with the flow" :-), git is grabbing more focus recently especially after GitHub's strong support.

Lazy comparison of Git vs SVN commands

I thought a simplest way is to compare Git vs SVN was through the basic commands used for day-to-day development.  Though we use the UI tools for regular activities, I am listing down the comparison by commands (lazy).

Git vs SVN commands
Git vs SVN commands
Two notable operations are the checkout and commit.  For any Git operations "clone" is a prerequisite, so to do a checkout initially you must clone the repository. If you notice a commit is not an actual commit to the repository instead it is to your local.  You need to do an explicit push to the repo after a successful commit. Remember everything happens in your local and not in your repo.

Tuesday, April 30, 2013

How to add a Git submodule from eclipse EGit

Adding a submodule using eclipse

You can add a new submodule to a repository by selecting a repository in the Git Repositories view and selecting the Add Submodule context menu option.

The wizard will prompt for the path and URL of the submodule being added. The path entered will be relative to the parent repository's working directory and the URL will be used to clone the repository locally.

Once the wizard is completed the submodule will be cloned, added to the index, and the submodule will be registered in the .gitmodules file as well as in the parent repository's .git/config file.

Credit: http://wiki.eclipse.org/EGit/User_Guide