the changes to one or more files on disk. ▪ Git allows files to be added incrementally to the stage area. 13 echo “print ‘hello world’” > test.py git status
repository. git add Snapshots the file in preparation for versioning. git commit Records file snapshots permanently in version history. git log Lists version history for a file. git rm --cached Removes the file from version control but preserves the file locally. git status Lists all new or modified files to be committed. 21
an independent line of development. ▪ A branch is a pointer to a commit. git checkout -b <branch_name> git branch <branch_name> git branch -a https://www.atlassian.com/git/tutorials/using-branches
Once you’ve finished working on a branch and have merged it into the main code base, you’re free to delete the branch without losing any history. git push origin --delete <branch_name> git branch -D <branch_name> https://www.atlassian.com/git/tutorials/using-branches
commits of a branch and integrate them into a another one. ▪ It creates a new “merge commit” ▪ It is a non-destructive operation * https://www.atlassian.com/git/tutorials/using-branches/git-merge git merge <branch_name>
temporarily shelves changes (staged/tracked) that can be reapplied later on. ▪ Useful when you need to quickly switch context and work on something else. git stash apply git stash list git stash pop git stash drop * https://www.atlassian.com/git/tutorials/saving-changes/git-stash
branches. git checkout Switch branches or restore working tree files. git merge Incorporates changes from a branch into the current branch. git clean Removes untracked files from the working tree. git stash Stashes the changes in a dirty working directory away. 37
by creating brand new commits for each commit in the original branch ▪ Trade-offs: safety and traceability ▪ Golden Rule: never use rebase on public branches * Atlassian Bitbucket. Merging vs. Rebasing. url: https://www.atlassian.com/git/tutorials/merging-vs-rebasing
for undoing changes. ▪ Forms of invocation: --soft, --mixed, --hard ▪ It moves both the HEAD and branch refs to a specific commit. * Atlassian Bitbucket. Resetting, Checking Out & Reverting. Url: https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting
for undoing changes. ▪ Forms of invocation: --soft, --mixed, --hard ▪ It moves both the HEAD and branch refs to a specific commit. * Atlassian Bitbucket. Resetting, Checking Out & Reverting. Url: https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting
that made changes you want to undo. ▪ Reverting undoes a commit by creating a new commit. ▪ It is a “safe” way to undo changes * Atlassian Bitbucket. Resetting, Checking Out & Reverting. Url: https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting