quick reference for git
- Check the active username and e-mail address
git config user.name
git config user.email
- Check the local repository status.
git status
- Compare files as needed.
git diff filename
- Add any new and modified files for the next commit.
git add -A
- Amend the commit message to describe changes and commit them.
git commit -m "commit message"
- Push the commit to the remote origin (amend branch name if needed).
git push -u origin main
- Confirm the latest commit in the log.
git log
- Create the new repository specifying only the repository name and owner.
- For Codeberg pages, set the repository name to "pages" (without quotes)
- Make sure any settings to initialize the repository with a readme, license or .gitIgnore file are disabled, otherwise files will be created that will conflict with the local working/staging directory
- Check that the default branch setting (in the advanced settings) is set to "main" (without quotes)
- Check the active username and e-mail address
git config user.name
git config user.email
- From the working/staging directory, initialise the local repository.
git init
- [Only if needed] If the default branch setting could not be set to "main" (without quotes), perform a "checkout" to set it now.
git checkout -b main
(Warning: If there are files in a connected remote repository, the "checkout" command will overwrite files in the local working/staging directory with the current version of those files from the remote repository.)
- Make sure any necessary .gitIgnore file is applied to the working/staging folder now.
- Check the local repository status.
git status
This should report "No commits yet" and "Nothing added to commit but untracked files present".
- Add any new and modified files for the next commit.
git add -A
- Amend the commit message to describe changes and commit them.
git commit -m "commit message"
- Add the remote origin (only needed the first time, amend url as needed).
git remote add origin https://codeberg.org/username/pages.git
- Push the commit to the remote origin (amend branch name if needed).
git push -u origin main
- Confirm the commit in the log.
git log
To remove and reapply a remote origin (in case the remote origin has been recreated since the local repository was last pushed, amend url as needed):
git remote remove origin
git remote add origin https://codeberg.org/ashraya/pages.git
check
git config -l
Look for user.name, user.email, and github.user.
change
set:
git config --global user.name "your username"
git config --global user.email "yourname@emailprovider.com"
Remove global to apply the change only to the current repository.
delete:
git config --global --unset user.name
git config --global --unset user.email
sometimes needed:
git config --global credential.username "your username"
git config --global credential.email "yourname@emailprovider.com"
This will also delete the changes in the local working directory! Ensure there is a copy elsewhere of all files that need to be retained.
- Reset to an earlier commit, deleting all subsequent commits
git reset --hard last-good-version-SHA1-hash
- Force push the change
git push origin HEAD --force