git config --global user.name "Nazmul Hosen" git config --global user.email "nazmul.ch11@gmail.com"
Connect to a remote repository If you haven't connected your local repository to a remote server, add the server to be able to push to it: git remote add origin
If you haven't connected your local repository to a remote server, add the server to be able to push to it:
git remote add originSometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.
git revert {commit_id}'
Delete the last commit Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:
git push origin +dd61ab32^:masterYou need to create a local branch that tracks a remote branch. The following command will create a local branch named daves_branch, tracking the remote branch origin/daves_branch. When you push your changes the remote branch will be updated.
git checkout --track origin/newsletter
error like this:
opt/lampp/bin/mysql.server: 264: kill: No such process
sollution:
I have seen same problem. Firstly i used these commands:
sudo chmod -R 777 /opt/lampp sudo chown -hR nobody /opt/lampp sudo chmod -R 755 /opt/lampp
Then;
sudo service mysql stop
So, you should restart the lampp:
sudo /opt/lampp/lampp restart
Temporarily switch to a different commit If you want to temporarily go back to it, fool around, then come back to where you are, all you have to do is check out the desired commit:
git checkout 0d1d7fc32
Or if you want to make commits while you're there, go ahead and make a new branch while you're at it:
git checkout -b old-state 0d1d7fc32
To go back to where you were, just check out the branch you were on again. (If you've made changes, as always when switching branches, you'll have to deal with them as appropriate. You could reset to throw them away; you could stash, checkout, stash pop to take them with you; you could commit them to a branch there if you want a branch there.)
Hard delete unpublished commits If, on the other hand, you want to really get rid of everything you've done since then, there are two possibilities. One, if you haven't published any of these commits, simply reset:
git reset --hard 0d1d7fc32
# Alternatively, if there's work to keep: git stash git reset --hard 0d1d7fc32 git stash pop # This saves the modifications, then reapplies that patch after resetting. # You could get merge conflicts, if you've modified things which were # changed since the commit you reset to.
Example:
git cherry-pick d42c389f
git checkout @ -- myfile.ext
- Rename your local branch. If you are on the branch you want to rename:
git branch -m new-name
If you are on a different branch:
git branch -m old-name new-name
- Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
- Reset the upstream branch for the new-name local branch. Switch to the branch and then:
git push origin -u new-name
You can request a list of all remote repositories that are currently connected to your local repository:
$ git remote -v origin https://test@github.com/test/example.git (fetch) origin https://test@github.com/test/example.git (push)
Use the "add" parameter if you want to connect a new remote repository, in this example named "production":
$ git remote add production https://test@github.com/test/example.git
.gitignore only applies to untracked files. If you are tracking a .pyc then .gitignore won't apply. Remove the .pyc with git rm and next time you do a git status it (and any others) won't show up in the list of untracked file and nor will it be automatically added.
Otherwise if you need to ignore a file already under version control, update the index to ignore changes to files already under version control:
git update-index --assume-unchanged
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
You made a commit and then realized you want to remove it. But, you still want to keep your changes. This is achieved by:
git reset --soft HEAD^