Basic Git Commands

Init, status, add, commit. Links: codequizzes

14 flashcards · Programming Languages · by lakesare

  1. How do you start Git and what is the process called?

    $ git init The process is called initializing a git repository

  2. How do you determine the current state of the project?

    $ git status

  3. Move all your changes since your last commit to the staging area.

    $ git add .

  4. Store the saved changes in the repository and add a message "first commit".

    $ git commit -m "first commit"

  5. Show a list of all the commits that have been made.

    $ git log

  6. How do you put your local repository (repo) on the GitHub server?

    a. create a new repository in github b. get the SSH key (SSH stands for secure shell) c. $ git remote add origin [SSH key - something like git@github.com…] d. $ git push -u origin master

  7. Take a git project from GitHub to your local machine to work on it.

    $ git pull origin master Or, if you are taking a project that is not already on your local machine, use $ git clone.

  8. Create a branch called working

    $ git checkout -b working

  9. List all of the branches.

    $ git branch

  10. Switch to the working branch

    $ git checkout working

  11. Merge the changes that were made in the working branch with the master branch.

    $ git checkout master $ git merge working

  12. Delete the working branch

    $ git branch -d working

  13. Put everything up on the remote repository.

    $ git push

  14. Pull a branch from a remote repository and create the branch locally

    git checkout -b fix_stuff origin/fix_stuff