Switch branch and ignore any changes without committing

Following is the way to do this:

git stash save
git checkout branch
// do something
git checkout oldbranch
git stash pop

Indeed what it says (to be complete):
git stash save OR git stash (when in working branchY)
then git checkout branchX do something on branchX such as git add/commit -m etc.
git checkout branchY again and
git stash pop to get back the stash



How to undo ‘git add’ before commit on git ?

We can undo git add before commit with the following command ..

git reset

Which will remove it from the current index (the “about to be committed” list) without changing anything else.

We can also use

git reset

without any file name to unstage all due changes. This can come in handy when there are too many files to be listed one by one in a reasonable amount of time.


Git clone into a non-empty directory?

We can do with the following steps that worked for me:

1st step: git init

// 2nd step: for https
git remote add origin https://username@bitbucket.org/username/repo.git

// OR

// 2nd step: for ssh
git remote add origin git@bitbucket.org:username/repo.git

3rd step: git fetch

4th step: git pull origin master

Another alternative but I did not try:

git init
git init add origin PATH/TO/REPO
git fetch
git reset origin/master
git checkout -t origin/master

Later I also tried this process and below is my problem and solution …

You might get the error “fatal: A branch named ‘master’ already exists.
Then it seems you are in the branch “master”. Then we can do the following extra steps to make it works…

#to add all the files except the untracked files
git add -u

# commit files from server to git
git commit -m “files from server to git”

# push all the files to git
git push origin master

After that you make lose some files on git since we pushed the files from server. In that case you may add the missing files later from vai server to git or vise versa.

For more: More explanation

xcrun: error: invalid active developer path macOS Sierra

giving me the following error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

How do I fix it?

Answer is simple – Open Terminal, and run the following:

xcode-select –install

It will tell you to install the necessary software to fix this issue.

Moyens-MBP:dwn moyen$ xcode-select –install
xcode-select: note: install requested for command line developer tools

Source: http://apple.stackexchange.com/questions/254380/macos-sierra-invalid-active-developer-path