Gitkraken Remove Repo



At its core, the branching model offered by Git is intended to help you avoid merging unstable code into the main codebase. Working with branches in Git is a breeze, especially if you’re working with the GitKraken Git client to visualize your repository. Let’s start by going over how to delete a Git branch locally using the command line. To add a new fork, first open a repository in GitKraken. Then click the + icon when hovering over Remote in the left panel and click on the GitHub.com or the GitHub Enterprise tab. If GitKraken does not detect an existing fork of this repo, the app will present the option to fork the repo and then add it as a remote. Please like the video if you enjoyed & subscribe for more.Check out my other videos: social media.

Google repo; In this post we will look at git subtree and show why it is an improvement – albeit not perfect – over git submodule. What is git subtree, and why should I use it? Git subtree lets you nest one repository inside another as a sub-directory. It is one of several ways Git projects can manage project dependencies.

Pushing and pulling are the keys to collaboration. 🤝

Adding Remotes

To add a new remote, click the icon when hovering over Remote in the left panel, then fill in the remote URL.

When using an integration such like with GitHub or Bitbucket, select the remotes from your collaborators in the dropdown box. This makes viewing other forks of the same repository quick and easy.

Note: When using an integration, the drop-down box will only display Forks of this repository. If you would like to add a remote that is not a fork you can still do so via the URL option.

You can identify remote branches in the graph through the following icons:

  • — GitHub
  • — Bitbucket
  • — GitLab
  • — Azure DevOps
  • — Other Remote Server

All remote branches are located in the left panel.

Push

Pushing takes any local changes , and making them available on the remote .

Push the currently checked out branch by clicking Push in the main toolbar, or by right clicking on the branch, and selecting Push.

Pushing attempts to upload any new commits to the remote branch, then fast-forward the remote to bring it up to date with the local repo.

If the remote branch cannot be fast-forwarded, the push will be refused. If this is the case, GitKraken will provide the option to Pull (fast-forward if possible), or .

Caution: Forcing a push is considered destructive because it overwrites the remote branch by replacing it with the local branch.

If the branch pushed does not exist on the remote, GitKraken will prompt you to name and create the new remote branch. This is typically the fork name followed by a slash, and the branch name. i.e. origin/my-branch.

Drag and drop to push

Drag and drop a branch to a remote to access the Push action. You may drag a branch to a remote branch on the graph, or to a remote branch listed in the left panel.

Fetching

Pulling and fetching take updates from the remote and get them into our local repo.

Fetch All

Fetching gets updates from remote branches, but does not update any files in your working directory.

Updates will appear in the graph, and also update any branches on the left to show how many commits you are ahead or behind.

When you're behind the remote, it means that there are commits on the remote branch which have not been incorporated into the local repo. Pull (fast-forward if possible) to get these changes on local.

If you are ahead of the remote branch, there are local commits that have not yet been pushed to the remote.

It is possible to be both ahead of and behind a remote. However if you are both ahead and behind a remote, you will not be able to perform a Pull (fast-forward if possible) as the branches have diverged. Consider rebasing onto the remote first.

GitKraken automatically fetches updates from your remote repositories every minute by default. You can change this setting from Preferences General menu.

Fast-forwarding

Fast forwarding moves the currently checked out commit to one that was added later, replaying all commits in between in the order which they happened.

To fast-forward your currently checked out commit, you can right click on the branch with newer commits, and select the Fast-Forward option from the menu.

Pulling

Pulling first performs a fetch and then incorporates any commits in the remote repository into the local copy.

There are three pulling options. Let's demonstrate what each one does by starting with an example 2 commits made locally, and 2 that have been made on the remote.

Pull (fast-forward if possible)

Pull (fast-forward if possible) fetches any updates on the remote branch, then attempts to fast-forward the local branch. If a fast-forward is not possible, a merge will be performed.

This is the default option for new GitKraken users.

Pull (fast-forward only)

Pull (fast-forward only) fetches any updates and then attempts a fast-forward. If a fast-forward is not possible, GitKraken will not make any changes to the local repo.

In our 2-commit example, a fast-forward is not possible as there are new commits added to both branches.

Pull (rebase)

Pull (rebase) stashes all commits on this branch, pulls in new commits from the remote, and then replays your commits. This has the added benefit of maintaining all commits in a single line, as opposed to creating branches which are then merged back together.

Note: Remember the golden rule of rebasing, 'Never rebase while you're on a public branch', which is covered in our blog post.

Setting a default pull option

Set the default pull option by clicking the down arrow to the right, and clicking on the circle button by each option.

Our interface page covers this and more.

Setting the upstream branch

Whenever pushing, pulling, or fetching, GitKraken gets updates from the Upstream branch.

The Upstream defaults to the remote branch where the local branch was checked out, but you may change the Upstream to push, pull, or fetch from different branch.

Right click on a branch to set the upstream or click the option.

Alternatively, drag and drop a branch to push instead of setting upstream.

When working with Git you will find that sometimes commits need to be…

When working with Git you will find that sometimes commits need to be removed as they have introduced a bug or need to be reworked.

If it is the last commit this is very straight forward. Simply run:

git reset HEAD^

This will pop off the latest commit but leave all of your changes to the files intact.

If you need to delete more than just the last commit there are two methods you can use. The first is using rebase this will allow you to remove one or more consecutive commits the other is cherry-pick which allows you to remove non consecutive commits.

Example git log

NumberHashCommit MessageAuthor
12c6a45b(HEAD) Adding public method to access protected methodTom
2ae45fabUpdates to database interfaceContractor 1
377b9b82Improving database interfaceContractor 2
43c9093cMerged develop branch into masterTom
5b3d92c5Adding new Event CMS ModulePaul
67feddbbAdding CMS class and filesTom
7a809379Adding project to GitTom

Using Rebase

Repo

Using the git log above we want to remove the following commits; 2 & 3 (ae45fab & 77b9b82). As they are consecutive commits we can use rebase.

git rebase --onto <branch name>~<first commit number to remove> <branch name>~<first commit to be kept> <branch name>

e.g to remove commits 2 & 3 above

git rebase --onto repair~3 repair~1 repair

Using Cherry Pick

Step 1: Find the commit before the commit you want to remove git log

Step 2: Checkout that commit git checkout <commit hash>

Step 3: Make a new branch using your current checkout commit git checkout -b <new branch>

Step 4: Now you need to add the commit after the removed commit git cherry-pick <commit hash>

Step 5: Now repeat Step 4 for all other commits you want to keep.

Step 6: Once all commits have been added to your new branch and have been commited. Check that everything is in the correct state and working as intended. Double check everything has been commited: git status

Step 7: Switch to your broken branch git checkout <broken branch>

Step 8: Now perform a hard reset on the broken branch to the commit prior to the one your want to remove git reset --hard <commit hash>

Step 9: Merge your fixed branch into this branch git merge <branch name>

Step 10: Push the merged changes back to origin. WARNING: This will overwrite the remote repo!git push --force origin <branch name>

You can do the process without creating a new branch by replacing Step 2 & 3 with Step 8 then not carry out Step 7 & 9.

Example

Say we want to remove commits 2 & 4 from the repo.

Gitkraken Remove Repos

  1. git checkout b3d92c5 Checkout the last usable commit.
  2. git checkout -b repair Create a new branch to work on.
  3. git cherry-pick 77b9b82 Run through commit 3.
  4. git cherry-pick 2c6a45b Run through commit 1.
  5. git checkout master Checkout master.
  6. git reset --hard b3d92c5 Reset master to last usable commit.
  7. git merge repair Merge our new branch onto master.
  8. git push --hard origin master Push master to the remote repo.

Gitkraken Remove Repository

Final note

Gitkraken Remove File From Repo

Git rebase & cherrypick are dangerous but powerful solutions that should only be used as a last option and only be undertaken by someone who knows what they are doing. Beware that both solutions could have adverse effects on other users who are working on the same repository / branch.

Gitkraken Remove Report

Finally remember to be careful and good luck!