git commands Flashcards
How would you clone https://github.com/libgit2/libgit into the current directory
git clone https://github.com/libgit2/libgit
How would you create a snapshot of the current state of all the tracked files in the repository.
git commit
How would you create a new branch named bugFix that points to current HEAD?
git branch bugFix
How would you create a new branch named bugFix that points to current HEAD? And update HEAD to point to bugFix?
git checkout -b bugFix
How would you create a new branch named bugFix that points to the commit at hash c0s0cv0s ?
git branch bugFIx c0s0cv0s
How would you create a new branch named bugFix at the grandparent of Head?
git branch bugFix HEAD~2
You are on main branch. bugFix has been updated in parallel with main. How would you create a new commit that has the change of both main and bugFix?
git merge bugFix;
What kind of merge is it if the HEAD is an ancestor of the branch you merge with?
Fast Forward
What command takes a set of commits that are not the ancestor of the current branch and brings them in to be ANCESTORS of the latest commit on the current branch. (Example: you want to get recent changes from main to be ancestors of bugFix.)
git checkout bugfix; git rebase main
If you don’t like the changes in the last commit, how could you create a new commit that does not include those changes?
git revert HEAD
How would you copy a series of specific commits (hashes 1234567 and 2345678) to be below your HEAD (current location), AND move the current branch and head pointers to last commit copied.
git cherry-pick 1234567 2345678
What command would open up an editor that would allow you to interactively move around the last 4 commits on your current branch?
git rebase -i HEAD~4
How would you permanently mark commit 3456789 with the label version1?
git tag version1 3456789
How would you get from the remote main, deltas for changes on main, without actually updating the files that display on the local filesystem?
git fetch
What command would create a new branch namedmyBranchand sets it to trackorigin/main and makes myBranch the current branch?
git checkout -b myBranch origin/main