Some Useful git Commands

Some Useful git Commands

Easy to remember but I will put it anayway

$ git status

What is untracked, modified or deleted. It's good to check this so you don't accidentally commit something to the repo that you really don't want to.

$ git add -A  (git add /path/to/a/file)

-A is to add everything you saw in the git status command. Or you could just choose individual files to add

$ git commit -m "message"

This commits the files in the add command to the repo. Use the -m flag to put a message to remind you what it was about.

$ git push origin master

Update the central repo, that you maybe using to deploy to production or share with other developers

$ git log

You may see something like this:

commit e7ae097b99bf9bc558c27401ab2dc4224091ece8 (HEAD -> master, origin/master, origin/HEAD)Author: vagrant <vagrant@homestead>Date:   Thu Jun 27 17:15:51 2019 +0000    extra clause in sql queries on the page controllercommit ec29fb38b060857207d6990a9441e4fb70967d03Author: vagrant <vagrant@homestead>Date:   Thu Jun 27 16:31:11 2019 +0000    deeper menu, and links on results pages

press "q" to esc from that

$git show ec29fb38b060857207d6990a9441e4fb70967d03:path/to/a/file

After viewing the log and deciding which historic version you want to view. You can now choose a commit to view by selecting the hash and writing the path to the file you want to view.

To create new repository at origin ( from a local repository. Follow this tutorial on as it's the best explanation.

Create new branch and check it out
$ git checkout -b issue53

Remove file from git index
$ git rm --cached path/to/problemfile

List remote branches
$ git ls-remote
$ git remote show [origin]

Delete remote branch
$ git push [origin] --delete [branch]

Delete local branch
$ git branch -d [branch]
$ git branch -D [branch] (force against warnings)

Checkout the branch that you want to bring merges from another branch into.
$ git checkout master
$ git merge #issue53