Git is a free and open source version control system. It can handle everything from small to very large projects with speed and efficiency. Below are just a few snippets of the common Git commands that are useful to know.
Repository Creation
git init [project_name]
- Create a new local repositorygit clone [project_url]
- Download an existing repositoryRepository Feedback
git status
- List new or modified files not committedgit log
- Show full change historyDealing with Branches
git branch
- List all local branchesgit branch -av
- List all local and remote branchesgit checkout [my_branch]
- Switch to a branchgit branch [new_branch]
- Create a new local branchgit branch -d [my_branch
- Delete a branchChanges in Git
git add [file_name]
- Stage a file (ready to commit)git add .
- stage all changed filesgit commit -m "some message"
- Commit all staged filesgit commit --amend
- Change last commitgit reset [file_name]
- Unstage file. keeping file changesGit Synchronization
git fetch --all
- Get all updates (branches) from remote repositorygit pull origin [branch_name]
- Update current branch with local changesgit push origin [branch_name]
- Update remote branch with local changes