Version Control System - the way to store the history of changes in certain files.
- Full history of every file, which gives you possibility to go back to previous version of your codebase, analyze source of bugs and fix them.
- Ability to work on a development team, where each member can modify similar parts of the code without pain.
- Ability to track each change and describe purpose of the change
- Connection to project management system
- Connection to bug tracking software
- Centralized version control - all project files are saved on a version control server. You pull and work only with certain files. You don't need full copy of your project locally.
- Distributed version control - you can clone a copy of a repository to your local machine, so you will have the full history of the project.
- Centralized:
- Subversion (SVN)
- Perforce
- Distributed:
- Git
- Mercurial
- GitHub - https://github.com/pricing
- Bitbucket - https://bitbucket.org/product/pricing
- GitLab - https://about.gitlab.com/pricing/
- Repository - data structure which stores your project files and directories.
- Commit - checkpoint, adds changes to head revision of repository.
- Branch - an active live of development.
- Conflict - a situation when several users made changes in the same file and trying to push them.
- Merge - bring content from one branch to another.
- Fetch - get branch missing files from remote repository.
- Pull - fetch and merge branch.
- Push - putting all modified local files into the remote repository.
- Rebase - reapply changes from a branch to a different state.
- Revision - synonym for commit.
- Tag - namespace that points to an object.
- Master - the default development branch.
- Initialize git repository on local machine
git init
- Specify remote repository
git remote add origin https://github.com/<username>/<repository_name>.git
- Adding files
git add example.txt
git add --all
git add .
git add src/
- Check current status
git status
- Reset added files
git reset
- Remove files from staging
git restore --staged <filename>
- Commit your changes
git commit -m "Remove old bug, add new one"
- Push change to the remote repository
git push <remote_name> <branch_name>
- Get changes from the remote
# runs 'fetch' and 'merge' by default, or 'rebase' if using --rebase flag
git pull <remote_name> <branch_name>
git pull
# downloads objects & files from repository
git fetch origin <branch_name>
git fetch
# clone repository to a local machine
git clone https://github.com/<username>/<repository_name>.git
- Create branch
git branch crazy-experiment
- Delete branch
git branch -d crazy-experiment
- Move to branch
git checkout crazy-experiment
- Show current branch
git branch
- Create and move to new branch
git checkout -b crazy-experiment
git merge crazy-experiment
- Removing commit
# locally
git reset --hard HEAD~1
# from remote
git push origin HEAD --force
- Stashing
# stash changes
git stash
# get from stash
git stash pop
- Squash commits
git rebase -i <commit_hash>
Change pick
to squash
for a commit you want to meld into a previous one.
pick 8f59fe1 initial commit
pick 7e9b63f add some feature # <---
squash 94d96b5 cleanup # <--- these two commits will be squashed together
- Reverting changes
git revert <commit_hash>
- Keep empty directory in VCS
Just place empty
.gitkeep
file in that directory
# Ignore all files & folders & subfloders
*
# Ignore all files with .txt extension
*.txt
# Ignore specific file
example.com
# Ignore specific directory (nested)
/dist
# Ignore specific files in specific directory
/dist/*.jpg
# Ignore specific files in specific directory (nested)
/dist/**/*.jpg
# Ignore directory except single file
/dist/*
!/dist/example.txt
# Ignore files by mask in name (will work with /dist/img/a/test.jpg, /dist/img/a1/test.jpeg etc)
/dist/img/a?/*.jp?g
.gitattributes
Gitflow - branching model for Git, authored by Vincent Driessen. Made for collaboration and easy maintenance.
Pros:
- Simultaneously development
- Staging
- Collaboration
- Hotfixes
Cons:
None
How it works
- Feature branches
- Development branch
- Release branch
- Merge to master and dev branches
- Hotfixes
Go to project settings: https://github.com//<repo_name>/settings
-
Issue templates in .github/ISSUES_TEMPLATE/*.md
- Bug report
- Feature request
- Custom template
-
Pull request templates in .github/PULL_REQUEST_TEMPLATE.md
### All Submissions:
* [ ] Have you followed the guidelines in our Contributing document?
* [ ] Have you checked to ensure there aren't other open
[Pull Requests](https://github.com/<username>/<repo_name>/pulls) for the same update/change?
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### New Feature Submissions:
1. [ ] Does your submission pass tests?
2. [ ] Have you lint your code locally prior to submission?
### Changes to Core Features:
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
* [ ] Have you written new tests for your core changes, as applicable?
* [ ] Have you successfully ran tests with your changes locally?
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website.