Last active
August 29, 2015 14:03
-
-
Save fahied/7e38ff2321e3acb41615 to your computer and use it in GitHub Desktop.
GIT Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change the current branch to master in git # | |
You can rename/remove master on remote, but this will be an issue if lots of people have based their work on the remote master branch and have pulled that branch in their local repo. | |
That might not be the case here since everyone seems to be working on branch 'seotweaks'. | |
In that case you can: | |
(Make a git remote --show to check how your remote is declared within your local repo. I will assume 'origin') | |
(Regarding GitHub, house9 comments: "I had to do one additional step, click the 'Admin' button on GitHub and set the 'Default Branch' to something other than 'master', then put it back afterwards") | |
git branch -m master master-old # rename master on local | |
git push origin master-old # create master-old on remote | |
git checkout -b master seotweaks # create a new local master on top of seotweaks | |
git push -f origin master # create master on remote | |
But again: | |
if other users try to pull while master is deleted on remote, their pulls will fail ("no such ref on remote") | |
when master is recreated on remote, a pull will attempt to merge that new master on their local (now old) master: lots of conflicts. They actually need to reset --hard their local master to the remote/master branch they will fetch, and forget about their current master. | |
Source : http://stackoverflow.com/questions/2763006/change-the-current-branch-to-master-in-git | |
--------------------------------------------------------------------------------------------- | |
# Remove directory from remote repository after adding them to .gitignore # | |
git rm --cached `git ls-files -i --exclude-from=.gitignore` | |
git commit -m 'Removed all files that are in the .gitignore' | |
git push origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment