3 homepage: https://git-scm.com
5 git: --fast-version-control
7 > Git is a fast, scalable, distributed revision control system with an
8 > unusually rich command set that provides both high-level operations and full
12 Github's [Git 'Hello World'](https://guides.github.com/activities/hello-world/)
13 is a good place to get started if you're new to git.
15 ### How to commit files
18 git add ./path/to/file1
19 git add ./path/to/file2
20 git commit -m "my summary for this commit"
23 ### How to ignore common files
25 In your project repository create a `.gitignore` file with patterns of fies to
35 ### How to create a branch
37 This will branch from the branch you're currently on.
40 git checkout -b my-branch-name
45 > To "rebase" simply means to undo any of your changes, apply updates from
46 > another branch first, and then replay your changes.
48 Rebase when fetching new updates
51 git pull --rebase origin master
54 Rebase a feature branch from master before a merge
62 # go back to your feature branch
63 git checkout my-feature
68 # fix conflicts if you need to, and then continue
69 git add ./my-merged-file
73 ### How to authenticate git with deploy tokens
76 [The Vanilla DevOps Git Credentials & Private Packages Cheatsheet](https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/):
78 First, update `.gitconfig` to handle each type of git URL (git, ssh, and http)
82 git config --global url."https://api@github.com/".insteadOf "https://github.com/"
83 git config --global url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"
84 git config --global url."https://git@github.com/".insteadOf "git@github.com:"
87 Next, create a `.git-askpass`:
90 echo 'echo $MY_GIT_TOKEN' > $HOME/.git-askpass
91 chmod +x $HOME/.git-askpass
94 Finally, add the following ENVs to your deployment environment:
97 GIT_ASKPASS=$HOME/.git-askpass
99 # Relpace xxxx... with your deploy token
100 MY_GIT_TOKEN=xxxxxxxxxxxxxxxx
103 In the case of Github it may be useful to create a read-only deploy user for
106 This can work with Docker, Github, Gitlab, Gitea, CircleCI, and many more.