Differences between revisions 6 and 7
Revision 6 as of 2012-07-30 20:02:24
Size: 1433
Editor: SamatJain
Comment:
Revision 7 as of 2016-02-18 06:17:56
Size: 1644
Editor: SamatJain
Comment: Enforce .gitignore
Deletions are marked like this. Additions are marked like this.
Line 69: Line 69:
=== Enforce .gitignore ===

Remove files from the repository that should have been ignored by .gitignore:

{{{
git rm -r --cached .
git add .
git status
git commit -m ".gitignore is now working"
}}}

Workflow for gitorious and github

Initial checkout:

   1 # Fork repo on gitorious/github
   2 # Pull repo from gitorious/github
   3 # Add remote for upstream, e.g.
   4 cd Spoon-Knife
   5 git remote add upstream git://github.com/octocat/Spoon-Knife.git
   6 git fetch upstream

When needing to merge upstream changes back into master:

   1 git fetch upstream
   2 git merge upstream/master

Cookbook

Delete remote branch

git push origin :name-of-remote-branch

Reverting changes

Amend the previous commit that has not been propogated (i.e. undo it, then start a new one with the pending changes in the index):

git commit --amend -a -m "New commit message"

Undo a commit that has not been propagated:

git reset --soft HEAD^

just changes the repository without changing the files you've edited on disk. However:

git reset --hard HEAD^

will reset both repository and revert files.

Once a commit that has been propagated, there is no way to undo. However, the following will create a new commit undoing the previous commit's changes:

git revert HEAD

Pull with rebase instead of merge

git pull --rebase

Configure a branch to always do a rebase instead of a merge:

git config branch.master.rebase true

Enforce .gitignore

Remove files from the repository that should have been ignored by .gitignore:

git rm -r --cached .
git add .
git status
git commit -m ".gitignore is now working"


CategoryCheatSheet

SamatsWiki: CheatSheet/Git (last edited 2023-03-01 08:30:42 by SamatJain)