xkcd

You clone a repository with git clone URL. For example, if you want to clone the Git linkable library called SUBDIR, you can do so like this:

$ git clone URL/SUBDIR

That creates a directory named SUBDIR, initializes a .git directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. If you go into the new SUBDIR directory that was just created, you’ll see the project files in there, ready to be worked on or used.

If you want to clone the repository into a directory named something like MYSUBDIR, you can specify the new directory name as an additional argument:

$ git clone URL/SUBDIR MYSUBDIR

That command does the same thing as the previous one, but the target directory is called MYSUBDIR.1

Note the source repo is called origin and your new local is master by default. Later on you can use git pull origin master, to get the newest version from remote origin repo.

###

git status

Example output:

To see all the diff in tracked files but are in unstaged state:

git diff

or

git diff path/to/a/given/file

Stage files

git add -A stages all changes

git add . stages new files and modifications, without deletions

git add -u stages modifications and deletions, without new files

Detail:

git add -A is equivalent to git add .; git add -u.

The important point about git add . is that it looks at the working tree and adds all those paths to the staged changes if they are either changed or are new and not ignored, it does not stage any ‘rm’ actions.

git add -u looks at all the already tracked files and stages the changes to those files if they are different or if they have been removed. It does not add any new files, it only stages changes to already tracked files.

git add -A is a handy shortcut for doing both of those.2

If you have already staged the changes with git add, you can see what patch you have staged with3

git diff --staged

When you get:

! [remote rejected] master -> master (push declined due to email privacy restrictions)

You should issue these command:

	git config --global user.email "XXXX@users.noreply.github.com" # https://github.com/settings/emails
	git rebase -i
	git commit --amend --reset-author
	git rebase --continue
	git push

More to check alias Todo

Bonus - something totaly different

Academic Writing in Markdown with special reference to its advantages and features like creating footnotes, bibliographical references.

Notes

  1. (Almost)All about git clone 

  2. Difference between “git add -A” and “git add .” SO 

  3. How to see changes to a file before commit? SO