Git and Version Control

Git (/ɡɪt/) is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).

Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development. Since 2005, Junio Hamano has been the core maintainer. As with most other distributed version control systems, and unlike most client–server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking abilities, independent of network access or a central server. Git is free and open-source software distributed under GNU General Public License Version 2.

from https://en.wikipedia.org/wiki/Git

What Is Credentials

Git has an internal interface for storing and retrieving credentials from system-specific helpers, as well as prompting the user for usernames and passwords. The git-credential command exposes this interface to scripts which may want to retrieve, store, or prompt for credentials in the same manner as Git. The design of this scriptable interface models the internal C API.

source

Using Git Collaboratively

Mods

Want to

Rename Branch

git branch -m master main

rename master to main

Rename The origin Remote To upstream

$ git remote rename origin upstream

You can also do this using git remote set-url, but it takes longer and is more steps.

source

Reset

Come back last commit, don’t delete commit content

git reset --soft HEAD^

See A File At A Specific Commit

source

git show <commitid>:filename

Show Helpful Guides That Come With Git

git help -g

source

Show The Latest Commit

source

git show
# or
git log -n1 -p

Use format patch To Suggest Code Changes

git format-patch HEAD^

source

What Will Be Done After Rename Branch On GitHub

git branch -m master main
git fetch origin
git branch -u origin/main main

ref:

  1. https://github.com/git-tips/tips
  2. Git Reference Manual
  3. GitHub Cheat Sheet
  4. Visual Git Cheat Sheet
  5. git - the simple guide
  6. Think Like (a) Git
  7. Pro Git book 2nd Edition
  8. A Visual Git Reference
  9. https://learngitbranching.js.org/
  10. https://github.com/sds/overcommit