Publishing a local branch:
git switch branch_name
git add .
git commit -m "some description"
git push --set-upstream origin branch_name
HEAD is a symbolic reference to the current branch
HEAD information:
git ls-files //new files added, not commited
git status //show current branch information (HEAD)
The three trees in git:
- working directory //work in progress - files saved, but not staged
- index //staging area; tracks the files staged with 'add'
- commit history //the chain of commits
// Undoing the most recent commit (files were not pushed)
git reset HEAD~ //undo a commit
git add . //add the altered files
git commit -c ORIG_HEAD //will open an editor to amend the old commit message
// Removing the last commit altogether
git reset --hard HEAD~1
// Undoing the last commit, but leaving the files and the index intact (sort of merging the undone commit with the previous one)
git reset --soft HEAD~1
// Force push the changes to remote (may require a change in permission settings on git platform)
git push -f origin master
// Refresh the list of remote branches
git remote update origin --prune
// Show the list of branches
git branch -a
// Deleting untracked files
git clean -f -x