Wednesday, April 24, 2013

A first time using Git, with Bitbucket - add existing code.

If you are new to Git, it can be a bit much to get your head around. The content below assumes you are making use of - a good alternative for small commercial teams, which is roughly as good as Github in a number of areas.

Git (Windows)
First, let's get a git client. If you are on windows, I recommend one called msysgit. It gives you access to a start menu item, known as Git Bash - this will look and feel a lot like a Linux terminal.

  2. Grab Git-, the "Official installer for windows"
  3. Install, next, next, next, leave the line endings settings to whatever it defaulted to, next some more, SUCCESS!

Much of the bitbucket UI for signup, create repository, etc is fairly self explanatory. Let's go ahead and create a repository.

When you've done that successfully, you'll be confronted with a screen:

  • I am starting from scratch
  • I have code to import

Selecting "I have code to import" will give you a number of git commands as examples - to initialize a repository, to add your content, and to add a remote.

There are two main protocols that git can make use of - https and ssh. The https URLs look like

... and for the moment, are the simplest to understand. If you already know about SSH and SSH keys, use the other protocol.

When you add a remote, you give it a name - in this case, origin. This is just a shortcut for the bitbucket server - you can choose any name you like; however there is a widespread convention to use origin with the main repository.

For windows users,

  • Start
  • Git Bash - this is much like the windows command line (cmd), with a few different commands.
  • Find your existing code - cd /c/path/on/your/hard/disk - note the direction of the slashes!
In Git Bash, instead of seeing a prompt like c:\>, the prompt ends in a $. 

To get to your c:\ drive
$ cd /c/

To get to another path
$ cd /c/path/to/location

If you aren't sure, you can hit the TAB key repeatedly to autocomplete your filenames or show you a list of suggestions.

Once you have located the right directory with your existing code, we want to initialize a repository

$ git init

Next, add a remote called origin pointing at bitbucket.
$ git remote add origin

Tell Git to monitor the files - this is like an svn add.
$ git add .

To see the affect of git add, do
$ git status
# On branch master
# Initial commit
# Changes to be committed:
#   (use "git rm --cached ..." to unstage)
#       new file:   A.xml
#       new file:
#       new file:   C.wsdl
#       new file:   D.wsdl
you@yourcomputer ~/path/to/local/code (master)

You can see the code is now being tracked. It wants you to commit.

So, perform your first commit:
$ git commit -m "Importing my code" -a

[master (root-commit) 0bba05d] Importing my code
 4 files changed, 127 insertions(+)

All done, right? Not quite. You've made a commit, but this is only local to your repository. Think of it as the save command in a word document - it doesn't publish anything, but it lets you undo/redo changes.
From here you can do as many changes and as many commits as you want.

$ git commit -m "fix typo"
$ git commit -m "remove swearwords"

Also, you probably saw some warnings like:

*** Please tell me who you are.

  git config --global ""
  git config --global "Your Name"

It's worth doing this, as each commit is attributed to a user - you'll only have to do this once. Don't worry too much: your commit will still have succeeded.

Anyway, you can check the status again with
$ git status
# On branch master
nothing to commit, working directory clean

It should tell you if there are any untracked files (git add them), or uncommmited files (git commit them) - but ideally, it should look like the above.

To publish your changes, you need to push them. For simplicity, we'll also set a default destination (via -u) - the origin remote repository; master branch.

$ git push -u origin master
Password for '':
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 3.81 KiB, done.
Total 6 (delta 1), reused 0 (delta 0)
remote: bb/acl: you is allowed. accepted payload.
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
you@yourcomputer ~/path/to/code (master)

... and check - your code should be published!

Great - but what just happened? If you look at the diagram, we've done everything on the left hand side - have a local, have a remote, and pushed changes. It's now possible for someone else to clone your repo, or fork it, and pull changes.

You can see that there can be many repositories - sometimes teams will maintain a 'core' repo, and people on the outside take a 'fork'.


Tarun K. said...

Thanks a lot for the tutorial. The Bitbucket official tutorial was really a pain to read. This got the work done simple and fast.


Unknown said...

Thanks to Admin for Sharing such useful Information. I really like your Blog. Addition to your Story here I am Contributing 1 more Similar Story Common used Git Commands Checklist for Developers.

Rajani said...

Great article. Thanks for sharing it with us.
DevOps Training
DevOps Online Training
DevOps Training in Ameerpet

Anu said...

Nicely written and great info. I really cannot thank you enough for sharing. DevOps Training in Bangalore | Certification | Online Training Course institute | DevOps Training in Hyderabad | Certification | Online Training Course institute | DevOps Training in Coimbatore | Certification | Online Training Course institute | DevOps Online Training | Certification | Devops Training Online

keerthana said...

wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
This article resolved my all queries.
PHP Training in Chennai | Certification | Online Training Course | Machine Learning Training in Chennai | Certification | Online Training Course | iOT Training in Chennai | Certification | Online Training Course | Blockchain Training in Chennai | Certification | Online Training Course | Open Stack Training in Chennai |
Certification | Online Training Course

un known said...

Thanks for sharing this information. I really Like Very Much.
best devops online training

Neeta Borse said...

This blog is very helpfull information thank you so much for sharing this.
Php projects with source code
Online examination system in php
Student management system in php
Php projects for students
Free source code for academic
Academic projects provider in nashik
Academic project free download

divya said...

I feel really happy to have seen your webpage.I am feeling grateful to read gave a nice information for us.please updating more stuff content...keep up!!

Data Science Training In Chennai

Data Science Online Training In Chennai

Data Science Training In Bangalore

Data Science Training In Hyderabad

Data Science Training In Coimbatore

Data Science Training

Data Science Online Training

Sages Marketing said...

Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well.

Security Guard License
Ontario Security License
Security License Ontario
Security License

Thank you..

VD World said...

very interesting, good job and thanks for sharing such a good blog. Seo Services Delhi

Author said...

Hi.Very Good Article.Thanks For Sharing. Keep Up Tha Good Work

SEO Training in Pune
SEO Training in Mumbai
SEO Training in Delhi
SEO Training in Bangalore
SEO Training in Hyderabad

un known said...

Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
devops online training
best devops online training
top devops online training

Manoj Patil said...

I read this post your post so nice and very informative post thanks for sharing this post. Youtube Mp3 Converter

Mike Johnson said...

Great post, but it would look better if it was a video. I usually use this site to get youtube likes and views for my video. If you decide to make video for youtube, I advise you to visit this site too

Pankaj Singh said...

Thank you so much for your efforts for this valuable blog, keep it up for more updates. Visit Ogen Infosystem for professional website designing and SEO Services in Delhi, India at an affordable price.
Best Website Designing Company in India

Subham said...

Great Content & Thanks For Sharing With oflox. Do You Want To Know How To Make Money From Mitron App

IamLinkfeeder said...

Purchasing Individual Health Insurance: 3 Essential Tips From a Health Insurance Specialist By Shaun P Avery. 2000 Backlink at cheapest
5000 Backlink at cheapest
Boost DA upto 15+ at cheapest
Boost DA upto 25+ at cheapest
Boost DA upto 35+ at cheapest
Boost DA upto 45+ at cheapest . Submitted On June 15, 2012 Suggest Article Comments Print ArticleShare this article on Facebook3Share this article on Twitter2Share

Shambhu said...

Even if you are armed with an abundance of knowledge in SEO, you may still need the services of a professional SEO company. Having strong knowledge of SEO is hardly sufficient in some cases. 2000 Backlink at cheapest
5000 Backlink at cheapest
Boost DA upto 15+ at cheapest
Boost DA upto 25+ at cheapest
Boost DA upto 35+ at cheapest
Boost DA upto 45+ at cheapest
Even if you are doing your best to attempt to obtain a good ranking for your website, you might still wind up wondering why your website is simply not doing well.

Evo Syah said...

When you think Indonesia, you probably picture its Labuan Bajo, and sunny beaches in Canggu. Yet, many people don’t realize that Indonesia is also a great place to start a business. According to International Labour Organization, there are about 700 thousand small businesses in Indonesia in 2018, which 57 million are small and medium sized enterprises Start Business in Indonesia

But what makes Indonesia so great? Major cities like Jakarta, Bandung, Yogyakarta, and Surabaya, an impressive university system, and low taxes means the Sunshine country is ripe with opportunity for savvy business owners. Keep reading to learn more about why Indonesia could be the perfect spot to start your new business!

Evo Syah said...

SEO adalah proses meningkatkan visibilitas dan peringkat website bisnis Anda di laman hasil penelusuran mesin telusur, seperti Google, Bing, dan Yahoo, sehingga memudahkan pelanggan menemukan produk atau layanan Anda secara online.

Kami menawarkan layanan Jasa SEO terbaik di Bali dengan Strategi Optimasi Situs Website secara tepat dan akurat sesuai dengan prinsip kerja mesin pencari.

Evo Syah said...

Satya Puri Studio is Bali architects have worked on historically-inspired homes & villa around the world — including “Lux Villa in Bali; Sukh Sagar Haveli in Jodhpur, Rajasthan; Kahani Paradise in Gokarna. Their work shows inspiration across history and styles, tied together with the goal of enhancing life through good design. Above all, Satya Puri Studio Architects aims to produce personalized living environments.

Evo Syah said...

Evo Syah adalah seorang Freelancer Website Developer Bali, dia sangat menyukai hobbynya dalam menelusuri setiap blok yang Anda di internet. Dia memiliki banyak pengetahuan tentang Digital Marketing dan bagaimana penerapan dalam bisnis.

SEO Personal said...

Exactly, the very information that I was looking for. I was looking for such kind of article on the Internet and finally ended up here. Thanks for the help!
Wedding hall in Meerut
Top 10 CBSE School in Meerut
SEO Expert in Meerut
Software Development Company In Delhi NCR
Digital Marketing Company in Hapur
Web Development Meerut
Non Availability of Birth Certificate in Kolkata
Website Design in Meerut

ram said...

It was wonderfull reading your article. Great writing styleIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder

Ashleel Londa said...

It was wonderfull reading your article. Great writing styleiamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder

Rohit said...

Kim Ravida is a lifestyle and business coach who helps women in business take powerful money actions and make solid, productiveIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder

call center software said...

I really want to appreciate the way to write this
Call Center Software
Call Center Solution
Call Center Solutions

IamLinkfeeder said...

David Forbes is president of Alliance Marketing Associates IncIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder

Thakur98 said...

We are used to the fact that we know only religious and public holidays and celebrate only them.Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder

Thakur98 said...

We are used to the fact that we know only religious and public holidays and celebrate only them.Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder

Nestle007 said...

Have a nice day! A well knowledgeable and high word content I have got from your site. Every word is sounding good and meaningful. This is an informative website and I am sure we will always gain something unique about fashion, lifestyle, historical some like this.

paito warna sydney

jago said...

I have been on the internet lately, looking for something to read and that is how I came across your site and saw this article of yours. So, I decided to see what it says and I find out that it is so amazing. You really did great work on your site and the articles you posted on it. You really take your time in writing this article and they are clearly detailed. Once again, you are good at article writing and I will be coming back to view more article updates on your site.

Shambhu said...

Annabelle loves to write and has been doing so for many years.Cheapest and Fastest Link Building and Link Indexing Service TECKUM IS ALL ABOUT TECH NEWS AND MOBILE REVIEWS. Best GPL Store

Kim Jolly said...

Hi, I'm kimjolly. It's my initiative for learning in the field of Mandarin in best chinese teachers UAE. if you are keen interested in learning Feel free to visit my website also contact our 24*7 assistance for all query related to learning Mandarin.

Londonlenders UK

Evermolpro said...

Evermore Technology let businesses avail greater lead generation and higher conversions with its technical expertise. Evermore also provides Website Designing and Development Company in Noida Ghaziabad for better online visibility and brand perception.

Juna Rorimpandey said...

click on one of the sites below to get a variety of the best tips and tricks in life. live hongkong

mariahayden said...

How To Talk To A Live Person At AT&T?
If you are clueless about How to Talk To a Live Person at AT&T, follow the steps mentioned here. First of all, call the service number at 1-800-922-0204, and when the automated system begins talking, you have to press 0. The automated system will ask you why you're calling. Press zero again. Enter your account PID and press # to get a live person at AT&T.
Related Blogs - 
How to setup and configure AOL Mail Settings
How To Change AOL Password
Quick Way to Download AOL Desktop Gold Windows 10
How to Fix AOL Not Working issue on iPhone
AT&T Email Not Working On iPad
Set up Att.Net Email Account On Windows

bamgosoowm said...

Thank you, I have recently been looking for info about this topic for ages and yours is the best I have discovered so far.
But, what about the bottom line? Are you sure about the source?부산달리기

Best Review Group said...

Great post. Thanks.

Website Designing Company said...

Website Development Agency India