We have updated the content of our program. To access the current Software Engineering curriculum visit curriculum.turing.edu.
Git Commands
A Summary of Commonly Used Commands
There are hundreds of different Git commands, but to get started you only need to remember a handful of them. Here is a summary of the commands you’ll use most often:
git initinitializes your local directory as a new git repository. You must run this before you can commit any of your work.git statusshows the current status of your repo. It will show you if you have any work that is unstaged, what branch you are on, how many commits you are ahead of the master remote on github, and other useful things.git diffshows you the changes in your unstaged code.git remote -vshows you all the remotes for your repo. Thevstands for verbose, which shows you the URL of the repository on github, if any, that your local repository is pointing to rather than just the name of the remote repo.git add .takes all unstaged work and stages it, making it ready to be committed. You can also specify a particular file to stage withgit add file-path/name-of-filegit commit -m "write commit message here"commits all staged work. It’s important to write a brief, clear commit message so you know what each commit is for. “Final commit” is not the commit message you’re looking for exactly 100% of the time.git pullonce you’ve committed all your local work and runninggit statusshows that you have nothing to commit, you pull down any changes from your remote. By default, this will pull from theoriginremote’smasterbranch. To be specific about which remote and branch to pull from, you can use:git pull name-of-remote name-of-branchgit pushpushes your local changes up to your remote. By default, this will push to theoriginremote’smasterbranch. Like pull, you can push to a specific remote and branch with:git push name-of-remote name-of-branch. This is useful if you are using branches and pull requests. If you get an error message, it’s probably because you haven’t pushed your local branch up to github yet. Trygit push -u name-of-remote name-of-branch.git branchshows you all your local branches and indicates which branch you are currently on.git checkout -b name-of-new-branchmakes a new branch and switches to that branch.git merge name-of-branchwill merge the specified branch into the branch you are currently on.git branch -d name-of-branch-to-deletedeletes the specified branchgit logwill show you the full list of commits and authors for your repohistorywill show you your past git commandsgit stashstashes any unstaged changes in your repository. They will not be present in your codebase, but they are not deleted.git stash popgives you back the last staged changes you stashedgit blame file-path/name-of-fileshows you line-by-line who wrote the code in the specified file. Useful when you have a question about how something works and want to figure out who to ask, and also great source of shame when you realize you wrote the chunk of code you’ve been swearing at for the last hour.