Topics of learning git and github in simple way. 😊
- GIT installed on your machine. If not, you can download it from official site
- Account on github.com
- What was a challanges for developers?
- What was another solution?
- What to do now?
- Version Control System
- VCS (Version Control System)
- track files/folders
- to work in team
- free and opensource
Two types of VCS
- Centralized version control
- Distributed version control
So git is distributed version control system.
- Website/Server to upload repository
- Backup functionality
- GUI for repo
- Manage team
A repository a.k.a. repo is nothing but a collection of source code.
NO !!!!!! GIT can also be used with others repository management system like bitbucket.
- Run
$ git init
command or you can directly clon repo usinggit clone <repo_url>
- Link remote repository with local using
$ git remote add origin <repo url>
command - Add project files to folder and adding it to stage area via
$ git add .
command - Commit staged files with
$ git commit -m <Message>
command - pull latest changes in local repo
$ git pull origin master
- Push all local repository commits to remote
$ git push origin master
-
git add
is a command used to add a file that is in the working directory to the staging area. -
git commit
is a command used to add all files that are staged to the local repository. -
git push
is a command used to add all committed files in the local repository to the remote repository. So in the remote repository, all files and changes will be visible to anyone with access to the remote repository. -
git fetch
is a command used to get files from the remote repository to the local repository but not into the working directory. -
git merge
is a command used to get the files from the local repository into the working directory. -
git pull
is command used to get files from the remote repository directly into the working directory. It is equivalent to agit fetch
and agit merge
. -
Other useful commands:
git status
,git log
,git reset
,git diff
- what are branches & commands?
- Feature/Task wise branch
- commands for create, checkout, merge & delete
$ git branch <branch name>
you're still on master
branch so for adding new features, you have to swicth on newly created branch. Follow next checkout step.
$ git checkout <branch name>
Add new fetaures in your working repo and push it on remote repo. Now you can see new branch in branch list of github.
$ git merge <source branch name>
Add new fetaures in your working repo and push it on remote repo. Now you can see new branch in branch list of github.
$ git branch -d <branch name>
- From local repo
$ git push origin -d <branch name>
- From remote repo
Specific points in history for repository called as release or versions.
Cretae tag in local repository
$ git tag <tag name>
Show list of tags in local repository
$ git tag
$ git show <tag name>
Push tag to remote repository
$ git push origin <tag name>
Delete tag from repository
$ git tag -d <tag name>
- From local repo
$ git push origin -d <tag name>
- From remote repo
No concept for checkout tags, but if you want it then you can create a branch with specific tag
$ git checkout -b <branch name> <tag name>
$ git checkout .
.gitignore
So what is it?
.gitignore
tells git which files (or patterns) it should ignore. It's usually used to avoid committing transient files from your working directory that aren't useful to other collaborators, such as compilation products, temporary files IDEs create, etc.
Thanks