User Tools

Site Tools


version_control:git_tips

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
version_control:git_tips [2016/04/21 02:45] – [Tips for Windows users] mithatversion_control:git_tips [2024/04/17 21:43] – [.gitignore] mithat
Line 1: Line 1:
 ====== Git tips ====== ====== Git tips ======
  
-===== Tips for Windows users =====+===== For Windows users =====
  
-On Windows, use **Git Bash** (in Windows Explorer, right click and //Git Bash Here//) to run git commands.+==== Use Git Bash ==== 
 + 
 +On Windows, use **Git Bash** (in Windows Explorer, right click and //Git Bash Here//) to run Git commands. 
 + 
 +A summary of the bash commands you are likely to need (outside of the ''git'' command) are [[#Bash tips|below]]. 
 + 
 +==== Creating .gitignore files ====
  
 If you try to create a ''.gitignore'' file using Windows Explorer, Windows will get angry with you. Instead, open Git Bash in your project directory and enter<code>touch .gitignore</code> If you try to create a ''.gitignore'' file using Windows Explorer, Windows will get angry with you. Instead, open Git Bash in your project directory and enter<code>touch .gitignore</code>
-If you are really, really want to use Windows Explorer, there are reports you can specify ''.gitignore.'' as the file name (with a trailing period) to fool Windows into accepting it. But who knows for how long. However you do it, be sure the file you create is called ''.gitignore'' (and not e.g., ''.gitignore.txt''and be sure you add ''.gitignore'' to the repository.+If you really, really want to use Windows Explorer, there are reports you can specify ''.gitignore.'' as the file name (with a trailing period) to fool Windows into accepting it. But who knows for how long. Whichever way you do it, be sure the file you create is called ''.gitignore'' and not, for example, ''.gitignore.txt'' and be sure you add ''.gitignore'' to the repository. 
 + 
 +Note that ''touch .gitignore'' will work in other OSes that use the bash shell as well (i.e., macOS and most Linux systems). 
 + 
  
-Note that ''touch .gitignore'' will work in other OSes that use the bash shell as well (i.e., most Linux and Mac systems). 
 ===== Initial configuration ===== ===== Initial configuration =====
  
-The first time you run git, it may get angry with you because you haven't configured your email and name. Just do what it says, or if you want to be proactive, open a command line interface and enter:<code bash>+The first time you run Git, it may get angry with you because you haven't configured your email and name. Just do what it says. If you prefer to be proactive, open a bash command line interface and enter:<code bash>
 git config --global user.name "Your Name" git config --global user.name "Your Name"
 git config --global user.email "you@example.com" git config --global user.email "you@example.com"
 </code> </code>
  
-The ''--global'' option will add the information to your global git profile so all new projects will use that information. You don't have to set a global ''user.name'' and ''user.email'', but things are a lot simpler if you do.+The ''%%--global%%'' option will add the information to your global git profile so all new projects will use that information. You don't have to set a global ''user.name'' and ''user.email'', but things are a lot simpler if you do.
  
-There are more settings you can configure documented [[https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup|here]].+There are more settings you can configure that are documented [[https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup|here]].
  
 ===== .gitignore ===== ===== .gitignore =====
-To make git ignore a specific file:+To make Git ignore a specific file:
 <file text .gitignore> <file text .gitignore>
-nastyfile.txt+my-passwords.txt
 </file> </file>
  
-To make git ignore all files with a ''.exe'' extension:+To make Git ignore all files with a ''.exe'' extension:
 <file text .gitignore> <file text .gitignore>
 *.exe *.exe
 </file> </file>
  
-To make git ignore all files in a directory called foo:+To make Git ignore all files in a directory called foo:
 <file text .gitignore> <file text .gitignore>
 foo/* foo/*
Line 45: Line 54:
 <file text .gitignore> <file text .gitignore>
 # Ignore specific files # Ignore specific files
-nastyfile.txt +my-passwords.txt 
-another-nastyfile.docx+banking-info.docx
  
 # Ignore compiled file(s) # Ignore compiled file(s)
Line 58: Line 67:
 ===== Bash tips ===== ===== Bash tips =====
  
-To change directories in bash:<code bash>cd {path-to-directory-using-forward-slashes}</code>+To change directories in bash:<code bash>cd path-to-directory-using-forward-slashes</code> 
 + 
 +Use forward slashes in path specifiers even though paths in Windows are normally specified using backslashes.
  
 ~ is a shortcut to your home (User) directory. So you could for example: <code bash>cd ~/Documents/Dev/MyProject</code> ~ is a shortcut to your home (User) directory. So you could for example: <code bash>cd ~/Documents/Dev/MyProject</code>
Line 66: Line 77:
 To list all the files (including hidden files) in a directory: <code bash>ls -la</code> To list all the files (including hidden files) in a directory: <code bash>ls -la</code>
  
-To create a new file <code bash>touch {filename}</code>+To create a new file <code bash>touch filename</code>
  
  
version_control/git_tips.txt · Last modified: 2024/04/17 22:54 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki