Common Git Commands
- Downloads and update in the files current branch local repository from remote repository
git pull
` Downloads changes from remote repository without merging them into current branch
git fetch
- Add a changed file into the staging area. To be ready for committing
git add <file>
git add . #(This will add all files that have been changed)
- Commit a file (Saving a snapshot of a file)
git commit -m "MSG HERE"
git commit --amend #(This will pop up a new window and allow changes to previous commit)
- Push changes into remote repository (Make sure to check if pushing to correct branch)
git push
- Check the statuses of files or changed files
git status
- Cloning/Downloading a repository
git clone "urlOfRepo"
- Creating a new branch based of a specific branch
git branch <newBranchName> #(Creates a branch but needs to be checkout)
git checkout -b <newBranchName> #(Shortcut creates and moves into new branch)
- View history of git
git log
#(q to quit)
Rebasing
- Allows you to integrate changes from one branch to another. Can be used to merge commits or apply commits from another branch
git rebase master #(Moves current branch HEAD to masters HEAD)
git rebase -i #(Allows you to modify current branch commits interactively)
Ignoring Files
- If you want to stop certain files from being tracked or considered in git, you can use a special file ".gitignore"
- Example .gitignore file, git will not notify the developer/user that these files have been modified.
app.config
node_modules
cache
public