git init
This will remove the version control system
rm -rf .git
git status
git log
git add .
git rm --cached -r .
git commit -m "Intial Commit"
git push origin master
git pull
git clone <url>
git pull origin <branch_name>
This command merges the remote branch with the local repository.
git branch <branch-name>
git branch
git merge <branch-name>
git checkout <branch-name>
git checkout -b feature/new-feature
git checkout <commit-hash>
Go to the latest commit of the working branch:
git checkout <branch-name>
This updates your working directory to the latest commit on the specified branch.
git reset [options] <commit-hash>
This resets the state of your repository to the specified commit.
git reset --soft <commit-hash>
This undoes the last commit but keeps the changes from that commit in the working directory and staging area.
git reset --hard <commit-hash>
This permanently moves the branch pointer to the specified commit, resets the staging area, and discards all changes in your working directory.
Note: After resetting, you may want to update the remote repository:
git push --force origin <branch-name>
git clean -n
git clean -f
Use this with caution, as it permanently deletes untracked files.
git revert <commit-hash>
This creates a new commit that undoes the changes made by a previous commit.
Git subtree allows you to embed one Git repository within another as a subdirectory.
git subtree add --prefix=subdir-name remote-repo.git branch-name