Create an account on GitHub.
ssh-keygen -t rsa -b 4096 -C "your_email@youremail.com"
See this for more.
cat ~/.ssh/id_rsa.pub
Copy the entire block, then follow the instructions here to add it to your account.
To push an updated commit, it's best to use this command to not overwrite a teammates commit. If you cannot push by running this command then update your local repo by pulling and rebasing, then run this command again.
git push --force-with-lease
Make sure new patchsets are created with git commit
. Using
git commit --amend
will change a commit already merged
upstream and lead to conflicts. Commit messages should have a format like
this:
Implement a thing Optional extended description that should be complete sentences. Fixes #42.
where 42
would be the issue number being closed by this PR.
The last line ensures the issue is automatically closed when the PR is
merged. Make sure each issue resolution is a separate branch and PR.
Any changes should be incorporated into the commit previously pushed by either amending or rebasing (not pushing a new commit on top of the old one). Gerrit tracks the revisions using the "Change-Id" line at the bottom of the commit message. Make sure this line does not change and remains the last line during commit message modifications. Otherwise, a new patchset will be created instead.
Verify this was done correctly by inspecting the output of git log
main..HEAD
. There should be only one commit listed and its Change-Id
should match the old one.
git commit --amend
If a new commit or commits were made while working, they should be squashed into the first before submitting it all as a new revision. To do so, run
git rebase -i <commit hash before your commits>
The first commit in the resulting generated file should be set to "r"
for "reword" if the commit message needs to be altered to include parts of
the other two commits. The other commits should be set to "f" for "fixup"
so their contents are squashed into the first commit. git
rebase
descriptions for other options are in the file comment.
git switch main
to get back to tip of maingit branch temp
git switch temp
git branch -f main temp
(fine if changes on main
were bad)git switch main
git reflog
git switch main
git merge HEAD@{1}
(where HEAD{1}
is
commit in temp branch from reflog)git branch -d temp
git rebase -i
with edit mentioned next to commitcommmit --amend
scenario -> git
rebase --continue
git commit --amend
)git
commit --amend
)git rebase -i
is a fantastic toolgit filter-branch --tree-filter 'rm -f largeFile.out'
HEAD
git diff --color-words
-Xrenormalize
)git submodule
git subtree
, git
stree
)git clone --depth=
git worktree
git log
--grep
git log -S
and git log -G
git bisect
run
git blame
(git blame
-M
, git gui blame
, etc.)git log -L
git switch --detach
, git
switch
git
clone --reference
git stash --keep-index
git filter-branch
or equivalent, like BFG Repo Cleaner
(large history rewriting)@{1}
, @{yesterday}
,
@{-1}
/ -
, git log -g
)git replace
or grafts)git notes