GIT EXPERIENCE

You are viewing an old version (v. 11) of this page.
The latest version is v. 63, last edited on Jun 15, 2019 (view differences | )
<< View previous version | view page history | view next version >>

Table Of Contents

How To: Switch “origin” of your GIT repository

> git remote set-url <remote name eg:origin> <new git url>

How To: Stashing your changes Original Post

While you are in the middle of working on something complicated, you find an unrelated but obvious and trivial bug. You would like to fix it before continuing. You can use git stash to save the current state of your work, and after fixing the bug (or, optionally after doing so on a different branch and then coming back), unstash the work-in-progress changes.

$ git stash save "work in progress"

This command will save your changes away to the stash, and reset your working tree and the index to match the tip of your current branch. Then you can make your fix as usual.

... edit and test ...
> git commit -a -m "your comment"

After that, you can go back to what you were working on with git stash apply:

> git stash apply

Stash Queue

You can also use stashing to queue up stashed changes.

> git stash list
stash@{0}: WIP on book: 51bea1d... fixed images
stash@{1}: WIP on master: 9705ae6... changed the browse code to the official repo

Then you can apply them individually with

> git stash apply stash@{1} 

Clear out the list with ''.

> git stash clear

How to: Delete a remote Git tag

Probably you don’t need to do this often (if ever at all) but just in case, here is how to delete a tag from a remote Git repository.

If you have a tag named ‘mytag’ then you would just do this:

> git tag -d mytag
> git push origin :refs/tags/mytag

That will remove ‘mytag’ from the remote repository (E.g Github).

How to: svn project as git repository

Checkout

> git svn clone <svn repo url>

Commit your changes

> git svn dcommit

Update your working copy

> git svn rebase

How to: Keeping a git fork in sync with the forked repo.

When you fork a git repo, probably you would like to keep in sync the forked repo with the original one. This is how I do it.

> git remote add <repo name> <git url>

Fetch

> git fetch <repo name>

This will create a branch, so then you just have to merge back:

> git checkout master
> git merge <repo name>/master

Commit those new changes:

> git commit -a -m "Sync to fork master"

How To: Tagging

Create the tag:

> git tag 1.0 -a

push your tag to the remote repository:

> git push --tags

How to: Convert from Subversion to Git

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.