surendar's Profile




  • To a specific commit, git creates a detached branch.

    $ git branch

    few things see like ,

    * (detached from 3i4j25)

    In the master branch  head you need to checkout to your master branch again:

    $ git checkout master

    In the detached branch command will automatically delete.

    git checkout doesn’t work, to lose code git  requires you to deal with these files.

    Stash your modifications

    $ git stash

    Discard the changes reset-ing the detached branch:

    $ git reset --hard

    Create a new branch with the previous modifications and commit them:

    $ git checkout -b my_new_branch
    $ git add my_file.ext
    $ git commit -m "My cool msg"
    $ git checkout master
    • 3 answers
    • 0 votes
  • To discard the changes,

    git checkout -- <file>
    git checkout branch

    To keep the changes,

    git stash save
    git checkout branch
    git stash pop
    • 4 answers
    • 0 votes
  • Git is probably before tracking the file.

    From the gitignore docs:  

    By using git rm –cached. you can stop tracking a file in currently tracked.

    Replacing  the project and username :

    git rm --cached [project].xcodeproj/project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate
    git commit -m "Removed file that shouldn't be tracked"

    Rather use the –a option to git commit that will add all files to modified or deleted.

    • 4 answers
    • 0 votes
  • Asked on January 10, 2019 in Git.

    Try this alternative code for  short Git version hash:

    git log -1 --abbrev-commit


    git log --abbrev-commit

    Tabulation  the log entries with shorten SHA-1 checksum.

    • 4 answers
    • 0 votes
  • Top of Google is”working on the wrong branch” to checkout the branch to be working on. No need to hoard anything:

    git checkout branch123

    Checkout the modified file  to stop  overwrite  the working directory,

    Update : This method will  work when the files is modified in the working directory for both master and branch123.


    • 4 answers
    • 0 votes
  • Try this  below solution:

    When the terminal  is similar to predicament keep in mind  to try and type ‘quit’, ‘exit’ as well as stop the key connection with’Ctrl + C’.

    • 4 answers
    • 0 votes
  • Asked on January 9, 2019 in Git.

    It is basically to switch your SSH identity when running the git commands.

    To the host alias approach in the below answer:

    • Work with any git commands or aliases, even if you can’t specify the remote explicitly.
    • Easier to work with many repositories because you only need to set it up once per client machine, not once per repository on each client machine.


    Small scripts and a git alias admin

    git admin push

    . You could even do git admin clone … to clone a repository that can access to using your “admin” key.

    Procedure  1: Create the alternative SSH keys, optionally set a passphrase in case you’re doing this on someone else’s machine.

    Procedure   2: Create a script called “” that runs stuff that uses SSH, but uses a given SSH key rather than the default:

    exec ssh ${SSH_KEYFILE+-i "$SSH_KEYFILE"} "[email protected]"

    Procedure    3: Create a script called “” that runs git commands using the given SSH key.

    SSH_KEYFILE=$1 GIT_SSH=${BASH_SOURCE%/*}/ exec git "${@:2}"

    Procedure    4: Add an alias using something appropriate for “PATH_TO_SCRIPTS_DIR” below:

    # Run git commands as the SSH identity provided by the keyfile ~/.ssh/admin
    git config --global alias.admin \!"PATH_TO_SCRIPTS_DIR/ ~/.ssh/admin"


    • 4 answers
    • 0 votes
  • Asked on January 8, 2019 in Git.

    Abort a git cherry-pick  is alternative below code:

    git reset --hard HEAD
    • 3 answers
    • 0 votes
  • You can’t ignore that directory/subdirectory to remove all files from the target directory from the repo and then ignore that folder.

    • 3 answers
    • 0 votes
  • You can easily checkout the individual files you missed/removed :

    git checkout HEAD path/to/file path/to/another_file

    Single changes intact with no computing.

    • 3 answers
    • 0 votes