1

Hi I am new to both GIT and BitBucket. I used tortoise SVN previously. Now I have a project which is has repository in BitBucket. All I want is create a separate branch from the master code and work in my local system and commit the changes back to BitBucket. So that other development team can see my commits.

The other development team asked me to install GIT in local machine and commit the changes from there. So I installed the GIT in my local system and registered my User name and Email ID in the Local GIT Bash Command Prompt using the following commands.

git config --global user.name "FIRST_NAME LAST_NAME"

git config --global user.email "MY_NAME@example.com"

And also I have installed "git-credential-winstore" mentioned the same installation guide. Can you please tell me the procedure or give me the link to the procedure for creating a branch in BitBucket and dump the code into my local system and commit to the Same branch after my changes are done.

Kiran
  • 1,177
  • 4
  • 18
  • 35

2 Answers2

0

Supposing you have been added to the BitBicket repo, you can:

  • clone the repo:

    git clone https://yourLogin@bitbucket.org/someUser/aRepo
    
  • create a branch locally, and add some commits:

    git checkout -b dev_aFeature
    git add ...
    git commit -m "..."
    
  • push that new branch

    git  push -u origin dev_aFeature
    

You will have to enter your BitBucket account password.

So you don't create a branch in BitBucket (a branch in Git is not a subfolder like in Subversion)

You create a branch locally, switch to it, work, and push that work (and that new branch) to your upstream repo (here a Bitbucket one).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi VonC. Thanks for the help. I have created the clone from BItBucket repository. But when I try to use the checkout command my git bash says that " $ checkout -b mylocal_branch sh.exe": checkout: command not found " message. Am I done anything wrong in the above command? And also what are the 3 dots after add command and commit -m command? I have to give the commands in the same way? – Kiran Jul 07 '14 at 12:45
  • @Kiran why did you type "checkout", and not "git checkout", as I have shown in my answer? – VonC Jul 07 '14 at 12:52
  • My bad. In previous tutorial they said some commands which work without git as prefix. I went into that mode and tried. But after prefixing git really done the trick. But the problem is I can't see the created branch in my local folder. I created branch as "mylocal_branch". But I can't see this folder anywhere in the system. When I go to master folder and right click hover on "git branch". It is showing as "master". Sorry if i'm bogging you. Thanks a lot for your response and time. – Kiran Jul 07 '14 at 13:21
  • 1
    @Kiran that is expected: see http://git-scm.com/book/en/Git-Branching-Rebasing. In Git, a branch isn't a folder, it is a market to your current commit: type `git branch -avvv` to see all the branches including the one you just created. – VonC Jul 07 '14 at 13:28
  • VonC Thanks for the help. Actually I have tried "git branch", but it returns nothing. Now "git branch -avvv" also return nothing. The main doubt is can I work on the files in my master folder where the clone is placed? Is it ok? Then in that folder it is showing "master" when checked with the git branch from right clicking on the master folder. – Kiran Jul 07 '14 at 13:42
  • Yes: that folder isn't the "master" folder, but the "repo" folder, in which you can switch back and forth between branches. Again, http://git-scm.com/book/en/Git-Branching-Rebasing can explain a lot. – VonC Jul 07 '14 at 13:54
0

I can tell you an easy way:

Step 1: Setup SSH Keys ur account

shiva@Shiva MINGW64 /f/GitRep/MyProject
$ ssh-keygen -t rsa

it gives results:

enter image description here

This key is available in your local c drive path is like :

enter image description here

Above Key, You must be added to your git email:

enter image description here

Step 2: Now, you can clone the Project from you repository

shiva@Shiva MINGW64 /f/GitRep/MyProject
$ git clone git@github.com:shivanandam/hello-world.git

It Gives the result: enter image description here

Py-Coder
  • 2,024
  • 1
  • 22
  • 28