Useful git stuff

Here are some helpful hints and tips when working with git.

Creating a new repo on github using their API

The below is a curl request you can run from the command line. Just change the user and add the name:

curl -u ‘USERNAME’ https://api.github.com/user/repos -d '{"name”:”REPONAME”}’
Set the remote to the repo on github (add the username sometimes):
git remote add origin https://karava@github.com/karava/testCommandLineCreation.git
check the url of the origin:
git remote get-url origin
Reference: https://help.github.com/en/articles/adding-an-existing-project-to-github-using-the-command-line

Fetch online repositories from github

Fetch repos using this:
curl https://api.github.com/users/karava/repos | grep -w '"name"'
Alternatively here is a tool that can be used to fetch repositories, submit pull requests, fork repos all from the command-line https://hub.github.com. What are the advantages of git command line tools: Some general tips: Questions:

How can you search commits/view commit history, or search view/merge history. For example if you want to go back in time and find out what was done, or what broke what? Or to find how some old code was implemented, or to find some code that was deleted. In particularly how would you find when code you deleted still lived in git?

Other useful git commands

Handling Merge conflicts

get picture from slides fix merge conflicts, usually keep yours or theirs? then commit the change the message will usually be “fixed merge conflicts” then git push

Branching

A Branch is a version of the repo. Each branch has its own commit history and current version
Tags: