history This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ==== Initialize a repository ==== <html><pre>git init</pre></html> ---- ==== Stage changes ==== <html> <pre>git add <span style="color: green;">file-name</span></pre> or unstage with <pre>git restore --staged <span style="color: green;">file-name</span></pre> or revert file to it's last staged version<pre>git restore <span style="color: green;">file-name</span></pre> </html> ---- ==== Commit changes ==== <html> <pre>git commit -m 'what you have changed'</pre> you can also change your latest commit: <pre>git commit <span style="color: red;">--amend</span> -m 'what I have changed'</pre> Or revert a file to the latest commit: <pre>git checkout <span style="green">commit-id</span>~1 -- file1/to/restore file2/to/restore</pre> </html> ---- ==== Working with branches ==== <html> To list all (remote and Local branches):<pre>git branch <span style="color: green;">-a</span></pre> To change name of current branche:<pre>git branch <span style="color: green;">-m</span> new-name</pre> <pre>git branch <span style="color: green;">-b</span> new-branche-name</pre> </html> ---- ==== Configure git ==== === Save login credentials === <html> <pre>git config --global credential.helper cache</pre> or remove them <pre>git config --global --unset credential.helper</pre> </html> ==== Change author name/email for all commits before commitX ==== ...and keep original date ...except the first commit. See next section for that <code>git rebase -r IdOfCommitX --exec 'git commit --amend --no-edit --reset-author --date="$(git log -n 1 --format=%aD)"'</code> ==== Change author name/email of first commit ==== <code> git cherry-pick firstCommitID --edit git commit --allow-empty </code> you may have to remove some new commits created in the proccess