merges files when there is more than one person working on the same file.
acts like a time capsule where you can check past commits if you ever need to go back.
- It's a distributed repo. Everyone has a copy on their machines.
- It's not in a central repository.
- You can work on it offline.
git config - global user.name "Philip John Basile"
Setting the author of the code
git config - global user.email email@example.com
Setting the author's email
git config - global color.ui true
turn on pretty colors
Initializes a Git repo in your chosen directory.
Sees what the current state of our project is and what has changed.
git commit -m 'add cute octocat story'
Stores the saved changes with a message describing what was changed.
git add octocat.txt
Tells Git to start tracking changes made to octocat.txt
git add README.txt LICENSE
adds the two files README.txt and LICENSE to the staging area.
git add *.txt
Adds all txt files in current directory
git add docs/*.txt
Adds all txt files in docs directory
git add docs/
Adds all files in docs directory
git add '*.txt'
Adds all txt files in the whole project
git add - all
adds all files to the staging area.
Git's journal that remembers all the changes we've committed so far in the order we committed them.
git remote add origin https://github.com/try-git/try_git.git
Pushes our local repo to the remote GitHub server.
git push -u origin master
The push command tells Git where to put our local commits when we're ready. The name of our remote is origin and the default local branch name is master. The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.
git pull origin master
Checks for changes on our GitHub repo and pulls down any new changes.
git diff HEAD
Views all of the merge conflicts. Since HEAD is used it diffs against our most recent commit.
git diff - staged
Lets you see the changes that were just staged.
git reset octofamily/octodog.txt
Lets you unstage files using the git reset command.
git checkout - octocat.txt
If you mess up, you can replace the changes in your working tree with the last content in head. Changes already added to the index, as well as new files, will be kept. This gets rid of all the changes since the last commit for octocat.txt.
git branch clean_up
Creates a copy of their code they can make separate commits to. Once done you merge this branch into the main master branch.
Lists the local branch(es).
git checkout clean_up
Switch from one branch to another.
git rm '*.txt'
This command will not only remove the actual files from disk, but will also stage the removal of the files for us.
git merge clean_up
Merges the changes from the clean_up branch into the master branch.
git branch -d clean_up
Delete a branch when you have merged its contents and do not need it anymore.
Moves content to the remote repo.