Git is a distributed revision control and source code management method. Git is developed for managing the Linux Kernel develpment and is designed and developed initially by Linus Torvalds.
The word Git is not an abbreviation, Git is Bristish English slang for a stupid or unpleasant person . According to Linus Torvalds “I’m an egotistical bastard, and I name all my projects after myself. First Linux now ‘git’ “
GitHub is a web based hosting service for software development projects that use the Git revision control system. GitHub offers both commercial plans (paid accounts) and free accounts for open source projects.
Working with github private repository – Few Steps to Follow
1. Should mandatorily have a github account
2. Should necessarily have permission to access the private repository, that which should be granted by the owner of the Repository
3. To checkout from the private repository
- a. Generate ssh-keygen , Give the filename where the key to be saved , we can choose the default filename, but take care , if there is already a key existing in that file , take a backup of the existing one and create the new key in the default path shown by the ssh-keygen command.
- b. If we have choosen the default path, open the file .ssh/id_rsa.pub and copy the key and give that to our github account settings ssh_key tab and save that key.
Now our local machine is ready to fetch the remote repo to our local machine
4. Change the name and the email address if necessary that needs to appear in the repository , once we start committing
git config --global user.name "name"
git config --global user.email "email_address”
5. To checkout the project from the remote repo
git clone <git@github.com:<repo_name>.git
6. If we wish to checkout a particular branch from the remote repo
git clone <git@github.com:<repo_name>.git
git checkout -b <required_branch> origin/<required_branch>
7. Now if we want to create a new branch locally and need to create the same in the centralised repo.
git checkout -b <new_branch>
git push origin <new_branch>
8. Now we are on the new branch that was created , We can cross-verify the current branch using the command
git branch
What all changes we do will affect the new_branch we created now.
9. Pushing the changes to the new_branch on the centralised repo
Make changes in the required file , for ex. x.txt
git add x.txt
git commit -m "first commit"
(This will commit to the head branch in our local repo.git push
(this will commit the changes to the new_branch in the centralised repo
10. To Merge another branch to our currently active local_branch
git merge <any_branch_from_remote_repo>
Few Useful Commands
git branch -d <branch name> (
To remove a branch)git pull
(git fetch + git merge)git show
(Shows information about a git object.)git remote -v
(Show remote repository names & locations.)
Should mandatorily have a github account