Basic git usage

Assuming you have already cloned a repository, the best place to start is with:

git status

This will show the current state of the files including the branch you are on and any untracked changes. If you’ve come back to a project after a few days off, this will remind you where you are (which branch) and what you were doing (un-committed changes and diffs).

‘git status’ may show modified files, such as:

On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   ../../../src/apps/sequencer/engine/generators/RandomGenerator.cpp

no changes added to commit (use "git add" and/or "git commit -a")

To find out what is different in your changed files, type:

 git diff ../../../src/apps/sequencer/engine/generators/RandomGenerator.cpp

If your diff output is formatted incorrectly (escape codes instead of colors), try:

git config --global core.pager "less -R"

To show all branches:

git branch -a

To create a new branch:

git checkout -b <NEW BRANCH NAME>

To change to a new branch:

git checkout <branch name here>

To change back to the “default” branch :

check checkout master

To delete a branch:

git branch -d <branch_name>

To commit your changes

git commit -m "comment here"

Upload your changes to github

git push --set-upstream origin <your-branch-name-here>

Leave a comment

Your email address will not be published. Required fields are marked *