So everyone needs to know how GIT works, or just how one can use GIT. So here we follow simplest steps to setup GIT and work easily with the version control and code sharing. No description, no extra words, simply the steps ( only for Windows ).

[Steps 1-3 – to make an account to host GIT repo] [Steps 4-6 – to make a repo on the github/bitbucket]

1. Sign Up on Github or Bitbucket – for remote hosting of your code

2. Developing open source? Github is best! It’s where the whole world develops open-source.

3. Developing private project? Bitbucket is best! It allows you to host infinite private repositories, without a single penny! You can also share your projects with your team members ( up to Four members for free! )

4. Now once you’ve signed up on any of the above, Click on Creato Repo link on bitbucket or + sign on Github.

5. Add your project details. And then you get the repo link as https://[hostname]/[username]/[reponame].git where [hostname] is either bitbucket.org or github.com, [username] is your username, and [reponame] is the name you gave to your repository.

6. And that’s it. Go to settings of bitbucket repo (Gear sign) if you wish to share the repo.

[Steps 7-10 – to setup and run GIT on your system]

7. Install GIT. From where? Well, here: http://git-scm.com/download/win

8. What next? Install it. Double click - next - ... - next - finish!

9. Well now go to your existing project directory or a new directory where you wish to make your project. Press [Shift]+[Right Click] and select Git Bash.

10. First time users: Run following commands to tell GIT who is using it.

$ git config --global user.name "Your name"

>code>$ git config –global user.email uesrname@emailhost.com

Remember the above steps are required just for one time.

11. Now to initialize a GIT repo in your system,

$ git init

12. Now configure it to your remote repo ( on github or bitbucket )

$ git remote add origin https://[hostname]/[username]/[reponame].git

13. Well now, write your code, do anything. But when to add to remote repo? Either when you need to share the latest codes, or when you have to release a new version or so on – simply, whenever you need to backup your code. Generally it’s good to add to remote repo every night or after every new feature. But how to? Simple commands:

$ git add .

$ git commit -m 'commit message'

$ git push -u origin master

Here the ‘commit message’ should be what-you-have-done-with-the-code-since-last-commit

14. And that’s it. Every time now you add something to your precious code, add it, commit it, and push it as above!

15. Now what’s next? Let’s say your teammate who’s also working on the same repo has updated a few features and pushed to the repo. Now to update your local codebase, following comes in handy.

$ git pull -u origin master

TERMINOLOGY:

1. repo – repository – the code base of your project

2. --global – used to affect GIT globally in your system, not to just that repo.

3. add .add means to add and the period ( . ) specifies to add everything. If you wish to add only a particular file or folder, use $ git add [filename/folder]

4. commit – it means like versioning – or say some next level, which particular position of codebase is saved with GIT.

5. origin – the main remote repo. You can add more repos by replacing origin with whatever you want.

6. master – the main branch of the repo – there can be many branches of a repo.

NOTE: This is a very brief tutorial considering everything runs smooth. In case of any error, write in the comments below, and I’ll be happy to help!

Leave a Reply

Your email address will not be published. Required fields are marked *