Git: Git is a distributed open source version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed.
-Search ‘git download’ or go to https://git-scm.com/downloads.
-Download exe file for windows and start to install as command line and finish.
-We use git commands to connect with central repository called github so that we can push or pull codes.
-Git basic commands: https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html
GitHub: GitHub is a web-based hosting service for version control using Git. It offers all of the distributed version control and source code management functionality of Git.
-Go to https://github.com/ and open your account.
How it works?
1)Tell Git who you are: git config –global user.name “Sam Smith”
git config –global user.email “sam@example.com”
2)Go to the folder/path you have your project/code: cd Gitdemo
3) Create a new local (.git) empty repository in your project folder: git init
Note: When you try to push your code to GitHub, you need your code to staging 1st then commit ; then Github will accept all the codes to central repository. Means to accept code in Github the code should be in commit and to be in commit the code should be in staging first.
4) Add entire code/a file to staging/index: git add *
OR git add <file name/file path>
5) Commit entire code: git commit -m “My first commit”
6) Status or List the files you’ve changed and those you still need to add or commit: git status
7) On 1st time Connect your local repository to a remote repository (github) where code will be push: git remote add origin <serverpath>
8)Push or Send changes to the master branch of your remote repository: git push origin master
Note: after the push command it will ask you user name & pass for Github account.
9)Checkout a repository or clone a fresh copy of a project first time to local machine/user: git clone /path/to/github repository
10)Checkout/pull a repository or get latest changes from the master/github to your local:
cd <local project folder/path>
git pull origin master
11) Branches:
i)Crate a new branch from master branch: git checkout -b <branchName>
ii) List all the branches in your repo, and also tell you what branch you’re currently in: git branch
iii) Switch from one branch to another: git checkout <branchName>
iv)push code from local to new develop branch NOT to master:
-Switch to develop branch following steps ii & iii
-Then follow steps 4, 5, & 6.
-Then push : git push origin develop
v) Marge develop branch to Master: -Switch to master branch: git checkout master
-Make sure you are up to date: git pull origin master
-Final command to merge develop branch to active branch: git merge develop
To know more Watch GitHub tutorials from Part 1-5