Basic Git Commands
Init, status, add, commit. Links: codequizzes
14 flashcards · Programming Languages · by lakesare
How do you start Git and what is the process called?
$ git init The process is called initializing a git repository
How do you determine the current state of the project?
$ git status
Move all your changes since your last commit to the staging area.
$ git add .
Store the saved changes in the repository and add a message "first commit".
$ git commit -m "first commit"
Show a list of all the commits that have been made.
$ git log
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
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.
Create a branch called working
$ git checkout -b working
List all of the branches.
$ git branch
Switch to the working branch
$ git checkout working
Merge the changes that were made in the working branch with the master branch.
$ git checkout master $ git merge working
Delete the working branch
$ git branch -d working
Put everything up on the remote repository.
$ git push
Pull a branch from a remote repository and create the branch locally
git checkout -b fix_stuff origin/fix_stuff