130 likes | 140 Views
Learn the basics of Git, a version control system that allows you to track changes in your source code projects. Discover how to set up Git, configure it, and use essential commands for branching, merging, and collaborating with others.
E N D
An Introduction By Sonali and Rasika
Purpose of introducing GIT • Required for the project • Show the versions of your code in the course of development • Show versions of your documentation.
What is GIT? • Tool for keeping a history on state of your source code projects • Version control System • Allows Collaborative Source Code Management
How To set up Git • Download Git at - http://git-scm.com/downloads • Sign-up with bit-bucket at https://bitbucket.org/ and create a 5 member free team. Invite other team members. • [optional] Install Git-hub GUI client for local machine: • windows - https://windows.github.com/ • Mac - https://mac.github.com/
Configuring Git • Download and install the latest version of GitHub for Windows or Mac. This will automatically install Gitand keep it up-to-date for you. • open the Git Shell application and type: • gitconfig --global user.name "YOUR NAME" • gitconfig --global user.email "YOUR EMAIL ADDRESS"
GIT Basic Commands git init //initializes git git add filename //adds file name git diff //prints difference made in files git commit -m “Message here ” //saved!! git status //prints status of current repository git log //history git push [options] origin branch_name//updates a remote repository with the changes made locally
Git Branching & Merging git branch //Shows all branches of current repository
Git creating branches Git branch branch_name
Commit in Branch git checkout branch_name //Goes to the branch git add . git commit -am “Message”
Merging git merge master branch_name //Used to merge your work with master git checkout -b branch_name //Creates new branch and goes to that branch git branch -d branch name //Deletes the given branch
Git Fetch git fetch upstream Fetches all the changes made to the original repo from whom you have forked Git pull git pull Directly pulls the update from the original repo toyour current working repo Git clone git clone new_repo_urlyour_name Creates a repo by your_name
How to go Back to the last commit? git checkout checksum_number git reset --hard checksum_number You will have same status as that commit's data !! Concept: It goes to a no branch state, one can make edits and also commit. But then you need to create that into new branch More information at: http://stackoverflow.com/questions/4114095/revert-to-a-previous-git-commit
Resources • Git commands - http://git-scm.com/book/commands • Git FAQs - https://help.github.com/ • Git Tutorial videos - http://git-scm.com/videos • Pro Git, a book - http://git-scm.com/book • Learn Git in 15 mins - https://try.github.io/levels/1/challenges/1 • Information on git pull, push and fetch – • http://gitref.org/remotes/