Trace: • git
Development:git
Table of Contents
Initialize a repository
git init
Stage changes
git add file-name
or unstage with
git restore --staged file-name
or revert file to it's last staged versiongit restore file-name
Commit changes
git commit -m 'what you have changed'you can also change your latest commit:
git commit --amend -m 'what I have changed'
Or revert a file to the latest commit:
git checkout commit-id~1 -- file1/to/restore file2/to/restore
Working with branches
To list all (remote and Local branches):
git branch -a
To change name of current branche:git branch -m new-name
git branch -b new-branche-name
Configure git
Save login credentials
git config --global credential.helper cacheor remove them
git config --global --unset credential.helper
Change author name/email for all commits before commitX
…and keep original date …except the first commit. See next section for that
git rebase -r IdOfCommitX --exec 'git commit --amend --no-edit --reset-author --date="$(git log -n 1 --format=%aD)"'
Change author name/email of first commit
git cherry-pick firstCommitID --edit git commit --allow-empty
you may have to remove some new commits created in the proccess