Git notes
Wed, Jan 16, 2019 · 2 minute readlinux
Notes for some git commands outside of usual pull/add/commit/push.
Worth noting that we run our own public/private Git repositories using Gogs.
See also the Git documentation.
Get URL of my repo
$ cd /repo/dir
$ git config --get remote.origin.url
ssh://user@server/whatdidilearn.today.git
Create new branch
Do some work in /repo/dir (e.g. deleted _config.yml) then create new branch.
$ git checkout -b hugo
D _config.yml
...
Switched to a new branch 'hugo'
Change working branch
$ git checkout hugo
...
Already on 'hugo'
Change a load of stuff, usual workflow - but push to new branch instead of master (the default)
$ git add .
$ git commit
$ git push origin hugo
Total 0 (delta 0), reused 0 (delta 0)
To ssh://user@server/bespoke-it-solutions/whatdidilearn.today.git
* [new branch] hugo -> hugo
Change default branch of local repo
Check difference in .git/config
before / after using -u
to update local default repository.
After this can do git push/pull without specifying branch.
Default branch has also been set to hugo in remote repo.
$ git push -u origin hugo
Branch hugo set up to track remote branch hugo from origin.
Everything up-to-date
$ git pull
Already up-to-date.
List branches
Default branch is highlighted.
$ git branch
* hugo
master
Change your user details
Should do this as they will be recorded against commits.
$ git config --global --edit
Change user details in pending commit
Will promot for commit message
$ git commit --amend --reset-author
Current status
$ git status
On branch hugo
Your branch is up-to-date with 'origin/hugo'.
nothing to commit, working tree clean