To list all remote repositories as shortnames connected to your local repository
git remote
To list all remote repositories with their url's connected to your local repository
git remote -v
To connect to a new remote repository
git remote add testtech https://testtech@github.com/testtechcomp/testtech.git
To disconnect remote repository from your local repository
git remote remove testech
To rename remote repository in your local repository
git rename testtech prodtech
To fetch all changes from a remote repository without changing any code in any of branches in your local repository
git fetch testtech
To list all local branches in your local repository
git branch
To list all remote branches in your local repository
git branch -r
git branch -r -v
To see all local branches and remote branches in your local repository
git branch -a
To create a copy of remote branch in your local repository
git fetch testtech
git fetch testtech unit_testing
git checkout testtech/unit_testing
git checkout -b unit_testing_local
To update your local branch with latest changes in remote repository
git fetch testtech <remote_branch_name>
git checkout <local_branch_name>
git merge testtech/<remote_branch_name>
To see latest commit ids, commit messages and tracking remote branch of all local branches
git branch -vv
To publish a local branch to remote branch
git push -u origin dev
To create a copy of remote branch in your local repository and also set tracking branch at same time
git checkout --track testtech/functional_testing
To set tracking branch of your local repository to a branch in remote repository
git branch -u testtech/unit_testing
To delete local branches
git branch -d <branch_name>
To delete remote branches
git push origin --delete <branch_name>
To undo the commits and delete also those commits
git reset --hard HEAD~1
git reset --hard 0ad5a7a6
To undo the commits and don't delete the file changes
git reset --soft HEAD~1
To create a new branch and with state of a particular commit
git checkout -b old-project-state 0ad5a7a6
To create a new branch with history of a particular branch irrespective what is your current branch
git checkout -b <new_branch_name> <branch_from_which_to_copy_history>
To remove files from staging area
git restore --staged <file>
To undo the changes in a file
git restore <file_name>
To see all commit history of current branch
git log
To merge all changes in a feature branch to current branch
git checkout <branch_name_to_which_we_want_changes>
git merge <feature_branch>
To remove the remote tracking branch info
git branch --unset-upstream
To set the remote tracking branch info
git branch --set-upstream-to=origin/new-branch
Top comments (0)