Git basics Flashcards
What is the command to initialize a repo?
git init
What is the command to save a commit?
git commit -m “message”
What is the command to add files to a git repo?
git add filename
for all files in current directory
git add .
What is the typical git sequence to keep track of changes in a directory?
- Make dir changes
- Add the changes
- Commit the changes to repo with a message
What are the best practices for writing a commit message?
Start with a short single line summary (less than 50 chars)
write in present tense
What is the command to view git logs?
git log
to show last n commits: git log -n 5
since a date:
git log –since/until
What command is use to tell which branch you are on and about untracked files?
git status
What command lets you discard changes in a tracked file?
git checkout – <file></file>
Command to list all branches and switch branch?
git branch - view all branches
git branch <branch> to create a new branch</branch>
How to connect a remote branch?
git remote add
<name> <url>
</url></name>
How does a rebase work vs a merge?
Merge adds changes from both branching paths on to the most recent common ancestor (add commits in parallel)
Rebase commits the branch in the parameter to the most recent common ancestor and then commits the current branch ahead of it (add commits in serial)
What is the command for rebasing?
git rebase <branch></branch>