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
We can undo git add before commit with the following command ..
Which will remove it from the current index (the “about to be committed” list) without changing anything else.
We can also use
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.
Amending the most recent commit message
git commit –amend
will open your editor, allowing you to change the commit message of the most recent commit.
Additionally, you can set the commit message directly in the command line with:
git commit –amend -m “New commit message”
Simply follow the following process….
git checkout branch_name
git pull origin branch_name
git checkout master
git merge branch_name
git push origin master
Here is very good explanation…
We can do with the following steps that worked for me:
1st step: git init
// 2nd step: for https
git remote add origin https://email@example.com/username/repo.git
// 2nd step: for ssh
git remote add origin firstname.lastname@example.org:username/repo.git
3rd step: git fetch
4th step: git pull origin master
Another alternative but I did not try:
git init add origin PATH/TO/REPO
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
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:
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
you can specify Git configuration settings with the git config command. One of the first things you did was set up your name and email address:
$ git config –global user.name “Moyen Uddin”
$ git config –global user.email email@example.com
useful link: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
we can get the files by the following commad..
git checkout source_branch file/files