whoami ?? Vikas S Yaligar @vikasyaligarhttps://github.com/vikassy
Why learn git??To manage your Project repository Sharing your code via github Contributing to others code
Contents➢ Git Introduction➢ Git Basic Commands➢ Git Branching & Merging➢ Github Introduction➢ Your app in Github➢ How to Contribute?
Git Is Open Source Version control System Tool for keeping a history on theDistributed Revision control state of your source codeSource code management projects.
Im an egotistical bastard,and I name all myprojects after myself. FirstLinux, now git Linus Torvalds
InstallationOn Linux sudo apt-get install git Version of gitOther systems git --version http://git-scm.com/
Git work flow
Git Basic Commandsgit init //initializes gitgit status //prints status of current repogit diff //prints difference made in filesgit add filename //adds file namegit commit -m “Message here :P” //saved!!git log //history
git initCreates a .git file in current folder Why??
BecauseTo tell git from where the file must be tracked !!!
git add To add particular files/folders to commitExamples:git add .git add test.cgit add somedirectory/file
How do I know which are added ? Using git status
git status Tells usabout untracked files and files added to commit How do i know what are the changes?
git diffTells the changes made in files
git commitgit commit -m “message here” -m => messagegit commit -am “message here:P”-a => To add the modified files and then commit Message is compulsory !!
git logTo show all commits with messages,check sum andmany more Checksum is always unique to each commit Can also use gitk, a commit viewer of git
How does it work??
.gitignoreTells git what to Ignore
Status & Review✔ Git Introduction✔ Git Basic Commands➢ Git Branching & Merging➢ Github Introduction➢ Your app in Github➢ How to Contribute?
Git Branching & Merginggit branch //Shows all branches of currrent repo
Git creating branchesGit branch branch_name
Commit in Branchgit checkout branch_name Goes to the branchgit add .git commit -am “Message”
Other optionsgit checkout -b branch_nameCreates new branch and goes to that branchgit branch -d branch nameDeletes the given branch
Merging git merge master branch_nameUsed to merge your work with master
Oh! I have to go back to last commit !!! How do I do that ???
git checkout checksum_number You will have same status as that commits data !!Concept: It goes to a no branch state, one canmake edits and also commit. But then you need tocreate that into new branch
Status & Review✔ Git Introduction✔ Git Basic Commands✔ Git Branching & Merging➢ Github Introduction➢ Your app in Github➢ How to Contribute?
Who uses github ??? Many More !!!!
GitHub is the best way to collaborate with others. Fork, send pull requestsand manage all your public and private git repositories.
Creating a new repo
Git remoteA remote in Git is basically a way to tell Git whereanother version of your repository is. Then you can ask Git to fetch data from it that you don’t have yet, or push your commits up to it (if you have write access).Git remote add origin https://github.com/username/project.git
Fork a repo !!
Git clonegit clone new_repo_url your_nameCreates a repo by your_name
Adding upstreamgit remote add upstreamhttps://github.com/username/rep.git Adds remote named upstream for your current repo
Fetch git fetch upstreamFetches all the changes made to the original repo fromwhom you have forked
Merge Git merge upstream/masterMerges the upstream with master branch
Git pullDirectly pulls the update from the original repo to yourcurrent working repo
There is a lot more to be learnt Thank you !!● Credits:● 1)Chandramouli , 3rd year , BTech.● 2)Tushar Makkar , 2nd year, BTech.● 3)Pramati , 2nd year , BTech .