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
version_control:git_tips [2019/02/21 18:59] – [Tips for Windows users] mithatversion_control:git_tips [2024/04/17 22:54] (current) – [.gitignore] mithat
Line 14: Line 14:
 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. 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., macOS and most Linux systems).
  
  
Line 20: Line 20:
 ===== 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. If you prefer to be proactive, open a bash 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"
Line 30: Line 30:
  
 ===== .gitignore ===== ===== .gitignore =====
 +The ''.gitignore'' file is used to tell Git to ignore (i.e., not track) certain files. The leading dot is important. The leading dot also tells macOS and Linux systems that it is a hidden file. To show hidden files in macOS's Finder, use ''Command'' + ''Shift'' + ''.'' In Linux, it depends on the file manager you are using. However, ''Ctrl'' + ''H'' is a common shortcut for this.
 +
 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>
  
Line 54: Line 56:
 <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 67: Line 69:
 ===== Bash tips ===== ===== Bash tips =====
  
-To change directories in bash:<code bash>cd {path-to-directory-using-forward-slashes}</code>+Git is typically controlled using a command-line interface. On Windows, the preferred interface is provided by Git Bash (see above). Most Linux systems provide Bash-based command-line interfaces by default. In addition, macOS's shell should be compatible with basic Bash commands.
  
-Use forward slashes in path specifiers even though paths in Windows are normally specified using backslashes.+So, here is a summary of some Bash commands to help you successfully use Git. 
 + 
 +To change directories:<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. Paths that start with a slash are absolute (i.e., they start at the top-level of your computer's file system). If you don't use a forward slash at the start of the path, the path is relative (i.e., what you enter will be appended to the current directory).
  
 ~ 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 75: Line 81:
 To navigate up one level: <code bash>cd ../</code> To navigate up one level: <code bash>cd ../</code>
  
-To list all the files (including hidden files) in a directory: <code bash>ls -la</code>+To list non-hidden files in a directory: <code bash>ls</code> 
 + 
 +To list **a**ll the files (including hidden files) in a directory in **l**ong form: <code bash>ls -la</code> 
 + 
 +The asterisk is a wildcard. So, to list all non-hidden ''.h'' files in the current directory: <code bash>ls *.h</code>
  
-To create a new file <code bash>touch {filename}</code>+To create a new file in the current directory: <code bash>touch filename</code>
  
 +To create a new directory in the current directory: <code bash>mkdir directoryname</code>
  
version_control/git_tips.1550775559.txt.gz · Last modified: 2019/02/21 18:59 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki