Git
Add SSH key to the ssh-agent:
1
$ eval "$(ssh-agent -s)"
2
$ ssh-add ~/.ssh/id_rsa
Copied!
Update to latest version:
1
$ sudo add-apt-repository ppa:git-core/ppa -y
2
$ sudo apt update
3
$ sudo apt install git -y
4
$ git version
Copied!
Show global origin config:
1
$ git config --list --show-origin
Copied!

Pull Requests

Syncing a forked repository:
1
# Add remote upstream
2
$ git remote add upstream https://github.com/original/repository.git
3
$ git fetch upstream
4
$ git rebase upstream/master (or git merge upstream/master)
5
​
6
# Update fork from original repo
7
$ git pull upstream master
8
​
9
# Push the updates to fork
10
$ git push -f origin master
Copied!
Working with a repository during a pull request:
1
$ git remote add upstream https://github.com/original/repository.git
2
$ git fetch upstream
3
$ git rebase upstream/master
4
$ git checkout upstream/master
5
$ git checkout -b new-feature
6
...Make changes...
7
$ gc -am "Add a new feature"
8
$ git push -u origin new-feature
Copied!

Signing Git Commits

Cache passphrase in gpg agent (dirty):
1
$ cd /tmp && touch aaa && gpg --sign aaa && rm aaa aaa.gpg && cd -
Copied!

Submodules

Edit submodule branch:
1
$ git config --file=.gitmodules -l | grep branch
2
$ git config --file=.gitmodules submodule.Submod.branch development
3
$ git submodule sync
4
$ git submodule update --init --recursive --remote
Copied!