-
-
Notifications
You must be signed in to change notification settings - Fork 6
Git
MidnightBSD moved to git in early 2020 for all development.
git clone https://github.com/MidnightBSD/src.git
(also works with svn or svnlite with github)
git clone [email protected]:MidnightBSD/src.git
git clone https://github.com/MidnightBSD/mports.git
git clone [email protected]:MidnightBSD/mports.git
There are at least two methods here. The first is to use git config and the second is environment variables.
git config --global user.name "John Doe"
git config --global user.email "[email protected]"
If you only want it for the current repo, don't use the --global
If you screw up a commit and need to fix it before setting this
git commit --amend --author="John Doe <[email protected]>"
It's global and overrides any git config settings, at least in some versions of git.
export GIT_AUTHOR_NAME="Midnight the Cat"
export GIT_AUTHOR_EMAIL="midnight@localhost"
(assuming you've cloned and are in the directory)
Change to the stable 1.2 branch
git checkout stable/1.2
See what branch you're on and other local branches as well as the most recent commit on them git branch -v
(assumes remote is called origin)
git remote show origin
It's best to read up on this one. https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages
This will walk you through each commit starting at the one you specified, which should be the last "good" commit.
git rebase -i -p 0ad14ff3
For example, if you want to fix author info:
git commit --amend --author="John Doe <[email protected]>" --no-edit
git rebase --continue
Renaming Remote Branches
rename locally
git checkout old-branch
git branch -m new-name
verify name
git branch -a
rename remote (assumes previous steps for local)
git push origin --delete old-name
git push origin -u new-name
git push remote_name -d remote_branch_name
If you start seeing ESC[ type escape sequences with git commands, you likely need to fix your pager.
One solution is
git config --global core.pager "less -R"
Patch for a specific commit
git format-patch -1 <sha>
src committers need to make vendor branches to track third party code.
The first option starts with creating a completely new directory and git repo outside of the src directory.
cd /some/where
mkdir foo
cd foo
git init
git checkout -b vendor/foo
The second option instead is to just run
git checkout --orphan vendor/foo
cp -r ~/foo/* .
git add *
git commit -m "Import foo 1.0"
cd /usr/src
git remote add foo /some/where/foo
git fetch foo vendor/foo
git worktree add ../foo vendor/foo
cd ../foo
git tag --annotate vendor/foo/1.0
git show
git push --follow-tags origin vendor/foo
cd ../src
git subtree add -P contrib/foo vendor/foo
git show
git commit --amend
git push origin
git worktree add ../foo vendor/foo
cd ../foo
rsync -va --del --exclude=".git" ~/git/foo .
git add -A
git status
git diff --staged
git commit -m "Vendor import of foo 1.0"
git tag -a vendor/foo/1.0
git push --follow-tags origin vendor/foo
cd ../src
git subtree merge -P contrib/foo vendor/foo
git worktree remove foo