Skip to content
EstebanMqz edited this page Mar 4, 2023 · 1 revision

Github Contributions              GitHub

Fork vs Clone:

  • Fork: Merge with original repo is possible with a pull request.

  • Clone: Merge with original repo is only achieved by pushing to fork and then a pull request.


Contributions without permissions:

Note: It is better to fork a repository before cloning it due to copyrights when the user is NOT declared as a contributor.


General steps:

  1. Fork repository.
  2. Clone forked repository.
  3. Make Changes in Local.
  4. Push to Personal Remote.
  5. Pull Request to Original Remote.


Contributions with permissions:

Note: It is a faster option to clone the original repository without a previous fork of the project if the user IS declared as a contributor.


General steps:

  1. Clone
  2. Make Changes in Local.
  3. Push to Personal Remote.

For more information about contributing to projects with Github refer to its official documentation.


Git Commands                 Git

Note: The following is a list of common syntax git commands but many more options are avaliable.
Refer to the official git documentation to view more available options.


Basic Command Description
1. init
  1. git init
  2. git init -b <branch-name>
  3. git init <subdir.>
  4. git init --bare <subdir.>
  5. git init --template=<template-dir.>
  6. git init --shared[=(-options)]
  1. Initialize git repo in folder.
  2. Override branch name (config. default set if none).
  3. Initialize a git repo inside a new subdir.
  4. Initialize a git bare repo inside new subdir.
  5. Specify dir. from which templates will be used.
  6. Make git readable/writable by users (see docs.).
2. clone
  1. git clone <URL>
  2. git clone --no-hardlinks <dir.>
  3. git clone <URL> <dir.>
  4. git clone <URL> --branch <branch> --single-branch
  5. git clone --bare
  6. git clone --mirror
  7. git clone --template=<temp_dir.> <dir.>
  1. Clone remote default branch with URL .
  2. Clone local repo for backup purposes.
  3. Clone remote default branch in dir.
  4. Clone remote single branch with repo URL.
  5. Clone remote with no remote-tracking & config.
  6. Clone --bare with remote tracking & config..
  7. Clone set template in dir. (See 5. git init).
3. config
  1. git config --global --edit
  2. git config --global user.name <username>
  3. git config --global user.email <e-mail>
  4. git config --system user.name <colab.>
  5. git config remote.origin.prune true
  6. git config --global fetch.prune true
  7. git config --get user.name
  8. git config ff no
  9. git config --global ff no
  1. Display git global config, (create if none).
  2. Set author to commits.
  3. Set email to commits.
  4. Set author for all git users.
  5. Set auto-prune with fetch & pull.
  6. Set auto-prune with git fetch.
  7. Get author/email from global/system (set args.).
  8. Disable fast-forward merges in local repo.
  9. Disable fast-forward merges in all local repos.
4. checkout
  1. git checkout <branch>
  2. git checkout -b <feature>
  3. git checkout -b <branch> <origin/branch>
  4. git checkout -- <file>
  5. git checkout -
  6. git checkout <branch>~n <file>
  1. Switch to branch in working tree.
  2. Create and switch to feature branch.
  3. Clone remote branch and switch.
  4. Discard changes in file.
  5. Switch to last checkout.
  6. Reverts local file in branch n commits (e.g. n=2).
5. fetch
  1. git fetch <origin>
  2. git fetch -u <origin> <branch>
  3. git fetch --all
  4. git fetch --dry-run
  5. git fetch --append
  6. git fetch --depth=<depth>
  1. Fetch all.
  2. Fetch branch.
  3. Fetch all branches in repo.
  4. Show output but without fetching.
  5. Fetch without overwriting (.git/FETCH_HEAD).
  6. Limit fetching to n depth commits (e.g. n=3).
6.merge
  1. git merge <branch>
  2. git merge <branch> <target_branch>
  3. git merge --no-ff <branch>
  4. git merge --continue
  5. git merge --allow-unrelated-histories
  6. git merge-base [-a] <commit> <commit> ...
  1. Fast-forward merge branch with HEAD (linear).
  2. Fast-forward merge branch to the tip of the target.
  3. Maintain commit history in merge (non linear).
  4. Conclude a conflicting merge.
  5. Merge indep. projects by overriding safeties.
  6. Find ancestor on n commits for a 3-way merge.
7. pull
  1. git pull
  2. git pull <URL>
  3. git pull <origin> <branch>
  4. git pull —rebase <origin> <branch>
  5. git pull --ff-only
  6. git pull --no-ff
  1. Fetch & merge remote-tracking with local.
  2. Clone, fetch & merge remote's URL with local.
  3. Fetch & merge remote branch with local.
  4. Fetch & rebase branch.
  5. Update branch without a merge commit.
  6. Pull & commit even for fast-forwards (linear).
8. add
  1. git add -A
  2. git add .
  3. git add <file>
  4. git add -n <file>
  5. git add --v
  6. git add -force
  1. Add all changes in files to stage.
  2. Add changes with no deletions for stage.
  3. Add file to stage.
  4. Show if file is unexistant.
  5. Ignore indexing errors for git add.
  6. Allows to add ignored files.
9. commit
  1. git commit -m <msg>
  2. git commit --date=<date>
  3. commit -i <msg>
  4. git commit --dry-run
  5. git commit -v
  6. git commit --amend
  1. Overwrite commit msg .
  2. Override author's date in commit.
  3. Commit changes & unstaged content.
  4. List commited, uncommited & untracked paths.
  5. Show differences between HEAD and commit.
  6. Modify the most recent commit msg.
10.push
  1. git push
  2. git push -u <origin> <branch>
  3. git push --all
  4. git push <origin> --delete <branch>
  5. git push --force
  6. git push --force-with-lease
  7. git push --prune <origin refs/heads/*>
  8. git push --mirror
  1. Push commits.
  2. Push commits and set as upstream.
  3. Push all commits.
  4. Delete remote-tracking branch.
  5. Push commits and destroy all unmerged changes.
  6. Push and destroy personal unmerged changes.
  7. Remove remote without local counterpart.
  8. Overwrite remote with local branches.
11.pull request
  1. git request-pull <tag> <URL> <feature>
  1. Pull request for changes between tag and feature.
12. branch
  1. git branch
  2. git branch -r
  3. git branch -a
  4. git branch <branch>
  5. git branch -d <branch>
  6. git branch -D <branch>
  7. git branch -f <branch> <feature>
  8. git branch --show-current
  9. git branch --set-upstream-to
  10. git branch / grep -v <branch(es)> / xargs git branch -D
  1. See local branches.
  2. See remote branches.
  3. See local and remote branches.
  4. Create branch and name it.
  5. Delete unmerged branch.
  6. Delete merged & unmerged branches.
  7. Rewrite local branch with feature branch.
  8. Show current branch in local.
  9. Make an existing git branch track a remote.
  10. Delete all branches excepting selected.
13. diff
  1. git diff
  2. git diff --staged
  3. git diff HEAD
  4. git diff --color-words
  5. git commit <ID 1> <ID 2>
  6. git diff <branch_1> <branch_2> <file>
  7. git diff <ID 1> <ID 2> <file>
  8. git diff --stats
  9. git diff-files¹
  1. Check for differences in local & remote-tracking.
  2. Check for differences in local & staged changes.
  3. Check for differences in work dir. & last commit.
  4. Highlight changes with color granularity.
  5. Check for differences for all commits.
  6. Check for differences in a file between two branches.
  7. Check for differences in a file between two commits.
  8. Show insertions & deletions in staged and local.
  9. Compare files in the working tree.
14. log
  1. git log -n
  2. git log --oneline
  3. git log -p --follow -- <file>
  4. git log --oneline --decorate
  5. git log --stats
  6. git shortlog
  7. git log --pretty=format:"%cn committed %h on %cd"
  8. git log --after=<yyyy-m-d> --before=<yyyy-m-d>
  9. git log --author=<username>
  1. Display logs from last 1,2,..n commits.
  2. Show IDs from commits.
  3. Show commits on a file.
  4. Display commits~branches.
  5. Show insertions & deletions.
  6. Display commits first coding line by author.
  7. Customized log (show author, hash & date).
  8. Search for commits in range.
  9. Search for commits by author.

Note: Remember to call branches by their names in your commands (See 12>3).
Tip: <main> is the default name for remote repositories as <master> is for local.


Definitions:

fetch: Fetch is the safe version of pull because local files aren't merged until they are reviewed, checked out & merged.

  • <master> ~ Default branch name of local repositories in Git.
  • <main> ~ Default branch name of remote repositories in GitHub.
  • <origin> ~ Primary working dir. of remote repositories by default.

See Also:
Glossary


Author:

EstebanMqz

Contact:

Feel free to send me an email if you have any questions.
Contributions are greatly appreciated!


Pending Commands:

  • git revert ~ pending
  • git restore ~ pending
  • git bisect ~ pending
  • git archive ~ pending
  • git status ~ pending
  • git remote ~ pending
  • git remote-helpers ~ pending
  • git filter-branch ~ pending
  • git rev-parse ~ pending
  • git describe ~ pending
  • git submodule ~ pending
  • git help ~ pending
  • git reset ~ pending
  • git switch ~ pending
  • git cli ~ pending
  • git shell ~ pending
  • git notes ~ pending
  • git reflog ~ pending
  • git rev-list ~ pending
  • git replace ~ pending
  • git rerere ~ pending
  • git update-index ~ pending
  • git bundle ~ pending
  • git send-email ~ pending
  • git web-browse ~ pending
  • git pack-objects ~ pending
  • git annotate ~ pending
  • git tar-tree ~ pending
  • git read-tree ~ pending
  • git mergetool ~ pending
  • git-sh-setup ~ pending
  • git var ~ pending
  • git gc ~ pending
  • git annex ~ pending
  • git stash ~ pending
  • git grep ~ pending
  • git show ~ pending
  • git exec ~ pending
  • git tag ~ pending
  • git whatchanged ~ pending
  • git show-ref ~ pending
  • git annex ~ pending
  • git difftool ~ pending
  • git receive-pack ~ pending
  • git rm ~ pending
  • git ls ~ pending
  • git ls-files ~ pending
  • git am ~ pending
  • git mk ~ pending
  • git cd ~ pending
  • gitrevisions ~ pending
  • gitattributes ~ pending
  • cg-admin-setuprepo ~ pending
  • etckeeper ~ pending
  • perlbrew ~ pending
  • guilt ~ pending
  • cd ~ pending
  • pass ~ pending
  • mr ~ pending
  • cg ~ pending
  • rpkg ~ pending

Other Commands:

  • git k ~ Show graphical representation of commits.
  • git k HEAD...FETCH_HEAD ~ Show everything that is reachable for users.
  • git --version ~ Show current version of git.
  • git * ~ Tutorial on git core commands.
  • git instaweb ~ Setup web server bound to local IP.
  • git frontend | git fast-import: Import large projects in a minimum amount of memory (100k+ commits on $2k PC in 1h). +$GIT_DIR/hooks/* ~more







                         Text-Editor: Visual Studio Code